Huginn

repository·master·Indexed 13 days ago

https://github.com/huginn/huginn

An open-source system for building autonomous agents that automate online tasks by creating and consuming events. It serves as a self-hosted, customizable alternative to services like Zapier or IFTTT, allowing users to automate workflows via website scraping, social media tracking, and connecting web services such as Slack, Twitter, RSS, and WebHooks.

Tokens
14.1K
Snippets
51
Records
72
Agent score
95%

What's inside Huginn

  1. Choose a Huginn Docker image

    master

    Huginn is available via two different Docker image strategies depending on your deployment needs:

    1. huginn/huginn (Multiple Process Image): Runs all Huginn processes within a single container. If no external database is linked, it automatically starts an internal MySQL instance. This is ideal for quick testing and prototyping, but it is more difficult to maintain and back up.

    2. huginn/huginn-single-process (Single Process Image): Follows the one-process-per-container pattern. This requires running multiple containers (at minimum one for the application server and one for the threaded background worker). This approach is more scalable and allows you to run multiple background workers in separate containers to improve performance.

  2. Run Huginn processes in separate containers

    master

    For production environments where you need to scale components individually, use the huginn/huginn-single-process image. This allows you to run each Huginn process (such as the web server, workers, etc.) in its own dedicated container.

    Detailed documentation for the single-process architecture can be found in the repository's docker/single-process directory.

  3. Extend Huginn with Agent gems

    master
    Complex or specific Agents can be written as external gems. You can add these to your Huginn installation by setting the ADDITIONAL_GEMS environment variable. If you want to develop your own agent gem, use the huginn_agent framework.
  4. Scale DelayedJob workers

    master

    A DelayedJob worker is a separate process that executes Huginn Agents (e.g., polling services, fetching websites).

    Scaling Logic:

    • One worker can perform exactly one check at a time.
    • Example: If you have 60 Agents checking websites every minute, and each check takes 1 second, a single worker is sufficient.
    • When to add workers: If you have a high volume of Agents or if the services/websites being polled are slow or unreliable, you should run additional workers.
  5. How Huginn works

    master
    Huginn is a system for building agents that perform automated tasks online. Agents create and consume events, propagating them along a directed graph. This allows you to automate tasks like scraping websites, watching for social media trends, tracking weather, or connecting various web services (e.g., Slack, Twitter, RSS, WebHooks) to create automated workflows.
  6. Update remote .env or Procfile and restart Huginn

    master

    Changes to the .env or Procfile must be performed directly on the server. After modifying these files, you must export the init scripts and restart Huginn to apply the changes.

    1. Navigate to the Huginn directory: cd /home/huginn/huginn
    2. Edit the desired file (e.g., Procfile or .env) using the huginn user.
    3. Export init scripts and restart: sudo rake production:export
    cd /home/huginn/huginn
    # Edit files as needed
    sudo -u huginn -H editor Procfile
    sudo -u huginn -H editor .env
    # Export init scripts and restart huginn
    sudo rake production:export
  7. Run Huginn locally using Docker

    master

    You can run a local instance of Huginn using Docker for testing or development purposes. Note that Docker is not recommended for production use.

    For detailed instructions, refer to the Docker installation guide.

    # See docker/install.md for specific commands
  8. Set up PostgreSQL for Huginn

    master

    To use PostgreSQL, install the server and libpq-dev. You will need to create a PostgreSQL user and a database named huginn_production owned by that user.

    # Install packages
    sudo apt-get install -y postgresql libpq-dev
    
    # Create Huginn user (will prompt for password)
    sudo -u postgres -H createuser -P huginn
    
    # Create the production database
    sudo -u postgres -H createdb -O huginn -T template0 huginn_production
    
    # Verify connection
    sudo -u huginn psql -h localhost -W huginn_production
  9. Install and export Huginn init scripts

    master

    Huginn uses foreman to manage processes defined in the Procfile.

    1. Edit Procfile: You can modify the Procfile to change process layouts (e.g., enabling separate schedule, twitter, or dj workers). Ensure there are no leading spaces before web: or jobs:.
    2. Export Scripts: Use the production export task to generate the init scripts.
    3. Re-exporting: You must re-run the export command every time you modify .env, Procfile, or config/puma.rb.

    Custom Log Directory: If you use a directory other than /home/huginn/huginn/, update the runit logfile location in lib/tasks/production.rake (e.g., run('foreman export runit -a huginn -l /opt/huginn/log /etc/service')).

    # Export the init scripts
    sudo bundle exec rake production:export
  10. Deploy Huginn to OpenShift

    master

    You can deploy Huginn to OpenShift Online using provided JSON templates. Use the following commands to create a new app with either MySQL or PostgreSQL:

    For MySQL:

    oc new-app -f https://raw.githubusercontent.com/huginn/huginn/master/openshift/templates/huginn-mysql.json

    For PostgreSQL:

    oc new-app -f https://raw.githubusercontent.com/huginn/huginn/master/openshift/templates/huginn-postgresql.json
    oc new-app -f https://raw.githubusercontent.com/huginn/huginn/master/openshift/templates/huginn-mysql.json
  11. Configure Huginn with environment variables and external databases

    master
    Huginn is configured via environment variables. When using Docker, you can link the Huginn container to an external MySQL or PostgreSQL database container. Detailed configuration parameters for database connection and other settings are available on the Docker Hub registry.
  12. Configure Capistrano on your local machine

    master

    To use Capistrano for deployments, add the following configuration keys to your local .env file. This tells Capistrano where to deploy, which user to use, and which repository to pull from.

    CAPISTRANO_DEPLOY_SERVER=<IP or FQDN of your server>
    CAPISTRANO_DEPLOY_USER=huginn
    CAPISTRANO_DEPLOY_REPO_URL=https://github.com/huginn/huginn.git