Merge pull request #872 from dsander/deployment-guide

Improve installation instructions

Dominik Sander 9 lat temu
rodzic
commit
c3e9545b6a

+ 9 - 0
.env.example

@@ -175,3 +175,12 @@ DELAYED_JOB_MAX_RUNTIME=2
175 175
 
176 176
 # Amount of seconds for delayed_job to sleep before checking for new jobs
177 177
 DELAYED_JOB_SLEEP_DELAY=10
178
+
179
+###############################################################
180
+# Capistrano deployment, read the documentation:              #
181
+# https://github.com/cantino/huginn/doc/manual/capistrano.md  #
182
+###############################################################
183
+
184
+#CAPISTRANO_DEPLOY_SERVER=
185
+#CAPISTRANO_DEPLOY_USER=
186
+#CAPISTRANO_DEPLOY_REPO_URL=

+ 1 - 0
.gitignore

@@ -25,3 +25,4 @@ deployment/cookbooks
25 25
 .ruby-gemset
26 26
 .ruby-version
27 27
 manifest.yml
28
+config/unicorn.rb

+ 8 - 2
Capfile

@@ -1,2 +1,8 @@
1
-load 'deploy'
2
-load 'config/deploy'
1
+# Load DSL and set up stages
2
+require 'capistrano/setup'
3
+# Include default deployment tasks
4
+require 'capistrano/deploy'
5
+
6
+require 'capistrano/bundler'
7
+require 'capistrano/rails/assets'
8
+require 'capistrano/rails/migrations'

+ 5 - 1
Gemfile

@@ -103,6 +103,10 @@ group :development do
103 103
   gem 'guard-rspec'
104 104
   gem 'letter_opener_web'
105 105
 
106
+  gem 'capistrano', '~> 3.4.0'
107
+  gem 'capistrano-rails', '~> 1.1'
108
+  gem 'capistrano-bundler', '~> 1.1.4'
109
+
106 110
   group :test do
107 111
     gem 'coveralls', require: false
108 112
     gem 'delorean'
@@ -120,6 +124,7 @@ end
120 124
 
121 125
 group :production do
122 126
   gem 'rack', '> 1.5.0'
127
+  gem 'unicorn', '~> 4.9.0'
123 128
 end
124 129
 
125 130
 # Platform requirements.
@@ -145,6 +150,5 @@ end
145 150
 
146 151
 on_heroku do
147 152
   gem 'pg'
148
-  gem 'unicorn'
149 153
   gem 'rails_12factor', group: :production
150 154
 end

+ 24 - 3
Gemfile.lock

@@ -84,6 +84,16 @@ GEM
84 84
       rails (>= 3.1)
85 85
     buftok (0.2.0)
86 86
     builder (3.2.2)
87
+    capistrano (3.4.0)
88
+      i18n
89
+      rake (>= 10.0.0)
90
+      sshkit (~> 1.3)
91
+    capistrano-bundler (1.1.4)
92
+      capistrano (~> 3.1)
93
+      sshkit (~> 1.2)
94
+    capistrano-rails (1.1.3)
95
+      capistrano (~> 3.1)
96
+      capistrano-bundler (~> 1.1)
87 97
     celluloid (0.16.0)
88 98
       timers (~> 4.0.0)
89 99
     chronic (0.10.2)
@@ -95,6 +105,7 @@ GEM
95 105
       coffee-script-source
96 106
       execjs
97 107
     coffee-script-source (1.9.1)
108
+    colorize (0.7.7)
98 109
     cookiejar (0.3.2)
99 110
     coveralls (0.7.1)
100 111
       multi_json (~> 1.3)
@@ -230,7 +241,7 @@ GEM
230 241
     kaminari (0.16.1)
231 242
       actionpack (>= 3.0.0)
232 243
       activesupport (>= 3.0.0)
233
-    kgio (2.9.2)
244
+    kgio (2.9.3)
234 245
     kramdown (1.3.3)
235 246
     launchy (2.4.2)
236 247
       addressable (~> 2.3)
@@ -267,6 +278,9 @@ GEM
267 278
     mysql2 (0.3.16)
268 279
     naught (1.0.0)
269 280
     net-ftp-list (3.2.8)
281
+    net-scp (1.2.1)
282
+      net-ssh (>= 2.6.5)
283
+    net-ssh (2.9.2)
270 284
     netrc (0.10.3)
271 285
     nokogiri (1.6.6.2)
272 286
       mini_portile (~> 0.6.0)
@@ -425,6 +439,10 @@ GEM
425 439
       actionpack (>= 3.0)
426 440
       activesupport (>= 3.0)
427 441
       sprockets (>= 2.8, < 4.0)
442
+    sshkit (1.7.1)
443
+      colorize (>= 0.7.0)
444
+      net-scp (>= 1.1.2)
445
+      net-ssh (>= 2.8.0)
428 446
     string-scrub (0.0.5)
429 447
     systemu (2.6.4)
430 448
     term-ansicolor (1.3.0)
@@ -472,7 +490,7 @@ GEM
472 490
     unf (0.1.4)
473 491
       unf_ext
474 492
     unf_ext (0.0.7.1)
475
-    unicorn (4.8.3)
493
+    unicorn (4.9.0)
476 494
       kgio (~> 2.6)
477 495
       rack
478 496
       raindrops (~> 0.7)
@@ -500,6 +518,9 @@ DEPENDENCIES
500 518
   binding_of_caller
501 519
   bootstrap-kaminari-views (~> 0.0.3)
502 520
   bundler (>= 1.5.0)
521
+  capistrano (~> 3.4.0)
522
+  capistrano-bundler (~> 1.1.4)
523
+  capistrano-rails (~> 1.1)
503 524
   coffee-rails (~> 4.1.0)
504 525
   coveralls
505 526
   daemons (~> 1.1.9)
@@ -576,7 +597,7 @@ DEPENDENCIES
576 597
   tzinfo (>= 1.2.0)
577 598
   tzinfo-data
578 599
   uglifier (>= 1.3.0)
579
-  unicorn
600
+  unicorn (~> 4.9.0)
580 601
   vcr
581 602
   webmock (~> 1.17.4)
582 603
   weibo_2!

+ 40 - 3
Procfile

@@ -1,13 +1,50 @@
1
+###############################
2
+#         DEVELOPMENT         #
3
+###############################
4
+
1 5
 # Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
2 6
 web: bundle exec rails server -b0.0.0.0
3 7
 jobs: bundle exec rails runner bin/threaded.rb
4 8
 
5
-# Possible Profile configuration for production:
6
-# web: bundle exec unicorn -c config/unicorn/production.rb
9
+# Old version with separate processes (use this if you have issues with the threaded version)
10
+# web: bundle exec rails server
11
+# schedule: bundle exec rails runner bin/schedule.rb
12
+# twitter: bundle exec rails runner bin/twitter_stream.rb
13
+# dj: bundle exec script/delayed_job run
14
+
15
+###############################
16
+#         PRODUCTION          #
17
+###############################
18
+
19
+# You need to copy or link config/unicorn.rb.example to config/unicorn.rb for both production versions.
20
+# Have a look at the deployment guides, if you want to set up huginn on your server:
21
+# https://github.com/cantino/huginn/doc
22
+
23
+# Using the threaded worker (consumes less RAM but can run slower)
24
+# web: bundle exec unicorn -c config/unicorn.rb
7 25
 # jobs: bundle exec rails runner bin/threaded.rb
8 26
 
9 27
 # Old version with separate processes (use this if you have issues with the threaded version)
10
-# web: bundle exec rails server -b0.0.0.0
28
+# web: bundle exec unicorn -c config/unicorn.rb
11 29
 # schedule: bundle exec rails runner bin/schedule.rb
12 30
 # twitter: bundle exec rails runner bin/twitter_stream.rb
13 31
 # dj: bundle exec script/delayed_job run
32
+
33
+###############################
34
+# Multiple DelayedJob workers #
35
+###############################
36
+# Per default Huginn can just run one agent at a time. Using a lot of agents or calling slow
37
+# external services frequently might require more DelayedJob workers (an indicator for this is
38
+# a backlog in your 'Job Management' page).
39
+# Every uncommented line starts an additional DelayedJob worker. This works for development, production
40
+# and for the threaded and separate worker processes. Keep in mind one worker needs about 300MB of RAM.
41
+#
42
+#dj2: bundle exec script/delayed_job -i 2 run
43
+#dj3: bundle exec script/delayed_job -i 3 run
44
+#dj4: bundle exec script/delayed_job -i 4 run
45
+#dj5: bundle exec script/delayed_job -i 5 run
46
+#dj6: bundle exec script/delayed_job -i 6 run
47
+#dj7: bundle exec script/delayed_job -i 7 run
48
+#dj8: bundle exec script/delayed_job -i 8 run
49
+#dj9: bundle exec script/delayed_job -i 9 run
50
+#dj10: bundle exec script/delayed_job -i 10 run

+ 12 - 2
README.md

@@ -53,7 +53,11 @@ And now, some example screenshots.  Below them are instructions to get you start
53 53
 
54 54
 ## Getting Started
55 55
 
56
-### Quick Start
56
+### Docker
57
+
58
+The quickest and easiest way to check out Huginn is to use the offical Docker image. Have a look at the [documentation](./doc/docker/install.md).
59
+
60
+### Local Installation
57 61
 
58 62
 If you just want to play around, you can simply fork this repository, then perform the following steps:
59 63
 
@@ -82,12 +86,18 @@ All agents have specs! Test all specs with `bundle exec rspec`, or test a specif
82 86
 
83 87
 ## Deployment
84 88
 
85
-Try Huginn on Heroku: [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) (Takes a few minutes to setup.  Be sure to click 'View it' after launch!)
89
+### Heroku
90
+
91
+Try Huginn on Heroku: [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) (Takes a few minutes to setup. Read the [documentation](./doc/heroku/install.md) while you are waiting and be sure to click 'View it' after launch!)
86 92
 
87 93
 Huginn works on the free version of Heroku [with limitations](https://github.com/cantino/huginn/wiki/Run-Huginn-for-free-on-Heroku). For non-experimental use, we recommend Heroku's cheapest paid plan or our Docker container.
88 94
 
89 95
 Please see [the Huginn Wiki](https://github.com/cantino/huginn/wiki#deploying-huginn) for detailed deployment strategies for different providers.
90 96
 
97
+### Manual installation on any server
98
+
99
+Have a look at the [installation guide](./doc/manual/README.md).
100
+
91 101
 ### Optional Setup
92 102
 
93 103
 #### Setup for private development

+ 54 - 0
config/deploy.rb

@@ -0,0 +1,54 @@
1
+require 'dotenv'
2
+Dotenv.load
3
+
4
+# config valid only for current version of Capistrano
5
+lock '3.4.0'
6
+
7
+set :application, 'huginn'
8
+set :repo_url, ENV['CAPISTRANO_DEPLOY_REPO_URL'] || 'https://github.com/cantino/huginn.git'
9
+
10
+# Default branch is :master
11
+set :branch, ENV['BRANCH'] || 'master'
12
+
13
+set :deploy_to, '/home/huginn'
14
+
15
+# Set to :debug for verbose ouput
16
+set :log_level, :info
17
+
18
+# Default value for :linked_files is []
19
+set :linked_files, fetch(:linked_files, []).push('.env', 'Procfile', 'config/unicorn.rb')
20
+
21
+# Default value for linked_dirs is []
22
+set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle')
23
+
24
+# Default value for keep_releases is 5
25
+# set :keep_releases, 5
26
+
27
+set :bundle_jobs, 4
28
+
29
+set :conditionally_migrate, true # Defaults to false. If true, it's skip migration if files in db/migrate not modified
30
+
31
+task :deploy => [:production]
32
+
33
+namespace :deploy do
34
+  after 'check:make_linked_dirs', :migrate_to_cap do
35
+    on roles(:all) do
36
+      # Try to migrate from the manual installation to capistrano directory structure
37
+      next if test('[ -L ~/huginn ]')
38
+      fetch(:linked_files).each do |f|
39
+        if !test("[ -f ~/shared/#{f} ] ") && test("[ -f ~/huginn/#{f} ]")
40
+          execute("cp ~/huginn/#{f} ~/shared/#{f}")
41
+        end
42
+      end
43
+      execute('mv ~/huginn ~/huginn.manual')
44
+      execute('ln -s ~/current ~/huginn')
45
+    end
46
+  end
47
+  after :publishing, :restart do
48
+    on roles(:all) do
49
+      within release_path do
50
+        execute :rake, 'production:restart'
51
+      end
52
+    end
53
+  end
54
+end

+ 1 - 0
config/deploy/production.rb

@@ -0,0 +1 @@
1
+server ENV['CAPISTRANO_DEPLOY_SERVER'], user: ENV['CAPISTRANO_DEPLOY_USER'] || 'huginn', roles: %w{app db web}

+ 9 - 9
deployment/site-cookbooks/huginn_production/files/default/unicorn.rb

@@ -1,24 +1,25 @@
1
-app_path = "/home/huginn/current"
1
+wd = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
+
3
+app_path = wd
2 4
 
3 5
 worker_processes 2
4 6
 preload_app true
5 7
 timeout 180
6
-listen '/home/huginn/shared/tmp/sockets/unicorn.sock'
8
+listen "#{wd}/tmp/sockets/unicorn.socket"
7 9
 
8 10
 working_directory app_path
9 11
 
10 12
 rails_env = ENV['RAILS_ENV'] || 'production'
11 13
 
12 14
 # Log everything to one file
13
-stderr_path "log/unicorn_out.log"
14
-stdout_path "log/unicorn_err.log"
15
+stderr_path "log/unicorn.log"
16
+stdout_path "log/unicorn.log"
15 17
 
16 18
 # Set master PID location
17
-pid '/home/huginn/shared/tmp/pids/unicorn.pid'
19
+pid "#{wd}/tmp/pids/unicorn.pid"
18 20
 
19 21
 before_fork do |server, worker|
20
-  defined?(ActiveRecord::Base) and
21
-    ActiveRecord::Base.connection.disconnect!
22
+  ActiveRecord::Base.connection.disconnect!
22 23
   old_pid = "#{server.config[:pid]}.oldbin"
23 24
   if File.exist?(old_pid) && server.pid != old_pid
24 25
     begin
@@ -30,6 +31,5 @@ before_fork do |server, worker|
30 31
 end
31 32
 
32 33
 after_fork do |server, worker|
33
-  defined?(ActiveRecord::Base) and
34
-    ActiveRecord::Base.establish_connection
34
+  ActiveRecord::Base.establish_connection
35 35
 end

+ 0 - 3
deployment/.chef/knife.rb

@@ -1,3 +0,0 @@
1
-cookbook_path ["cookbooks", "site-cookbooks"]
2
-role_path     "roles"
3
-data_bag_path "data_bags"

+ 0 - 11
deployment/Cheffile

@@ -1,11 +0,0 @@
1
-#!/usr/bin/env ruby
2
-#^syntax detection
3
-
4
-site 'http://community.opscode.com/api/v1'
5
-
6
-cookbook 'ark'
7
-cookbook 'runit'
8
-cookbook 'git', :git => 'git://github.com/opscode-cookbooks/git.git'
9
-cookbook 'nginx', :git => 'git://github.com/opscode-cookbooks/nginx.git'
10
-cookbook 'mysql', :git => 'git://github.com/opscode-cookbooks/mysql.git'
11
-cookbook 'nodejs', :git => 'git://github.com/redguide/nodejs.git'

+ 0 - 71
deployment/Cheffile.lock

@@ -1,71 +0,0 @@
1
-SITE
2
-  remote: http://community.opscode.com/api/v1
3
-  specs:
4
-    apt (2.4.0)
5
-    bluepill (2.3.1)
6
-      rsyslog (>= 0.0.0)
7
-    build-essential (2.0.2)
8
-    chef_handler (1.1.6)
9
-    dmg (2.2.0)
10
-    ohai (2.0.0)
11
-    rsyslog (1.12.2)
12
-    runit (1.5.10)
13
-      build-essential (>= 0.0.0)
14
-      yum (~> 3.0)
15
-      yum-epel (>= 0.0.0)
16
-    windows (1.31.0)
17
-      chef_handler (>= 0.0.0)
18
-    yum (3.2.0)
19
-    yum-epel (0.3.6)
20
-      yum (~> 3.0)
21
-
22
-GIT
23
-  remote: git://github.com/redguide/nodejs.git
24
-  ref: master
25
-  sha: 91d8d11f189d13815d56af5700168e1cad88ae7f
26
-  specs:
27
-    nodejs (1.3.0)
28
-      apt (>= 0.0.0)
29
-      build-essential (>= 0.0.0)
30
-      yum-epel (>= 0.0.0)
31
-
32
-GIT
33
-  remote: git://github.com/opscode-cookbooks/git.git
34
-  ref: master
35
-  sha: b1bca76aaf3a3a2131744f17f6e5087e22fa3c40
36
-  specs:
37
-    git (4.0.3)
38
-      build-essential (>= 0.0.0)
39
-      dmg (>= 0.0.0)
40
-      runit (>= 1.0)
41
-      windows (>= 0.0.0)
42
-      yum (~> 3.0)
43
-      yum-epel (>= 0.0.0)
44
-
45
-GIT
46
-  remote: git://github.com/opscode-cookbooks/mysql.git
47
-  ref: master
48
-  sha: 4b70e99730ab4a7ce6c1dd7a35654a764fb6e0fe
49
-  specs:
50
-    mysql (5.2.13)
51
-
52
-GIT
53
-  remote: git://github.com/opscode-cookbooks/nginx.git
54
-  ref: master
55
-  sha: 45588ee2a5c7144a0ef2a5992e7f273542236d27
56
-  specs:
57
-    nginx (2.7.3)
58
-      apt (~> 2.2)
59
-      bluepill (~> 2.3)
60
-      build-essential (~> 2.0)
61
-      ohai (~> 2.0)
62
-      runit (~> 1.2)
63
-      yum-epel (~> 0.3)
64
-
65
-DEPENDENCIES
66
-  git (>= 0)
67
-  mysql (>= 0)
68
-  nginx (>= 0)
69
-  nodejs (>= 0)
70
-  runit (>= 0)
71
-

+ 0 - 40
deployment/Vagrantfile

@@ -1,40 +0,0 @@
1
-# -*- mode: ruby -*-
2
-# vi: set ft=ruby :
3
-
4
-Vagrant.configure("2") do |config|
5
-  config.omnibus.chef_version = :latest
6
-
7
-  config.vm.provision :chef_solo do |chef|
8
-    chef.roles_path = "roles"
9
-    chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
10
-    chef.add_role("huginn_development")
11
-    # chef.add_role("huginn_production")
12
-  end
13
-
14
-  config.vm.provider :virtualbox do |vb, override|
15
-    #vb.memory = 1024
16
-    #vb.cpus = 4
17
-    override.vm.box = "hashicorp/precise64"
18
-    override.vm.network :forwarded_port, host: 3000, guest: 3000
19
-  end
20
-
21
-  config.vm.provider :parallels do |prl, override|
22
-    override.vm.box = "parallels/ubuntu-12.04"
23
-  end
24
-
25
-  config.vm.provider :aws do |aws, override|
26
-    aws.ami = ENV['AWS_AMI'] || "ami-828675f5"
27
-    aws.region = ENV['AWS_REGION'] || "eu-west-1"
28
-    aws.instance_type = "t1.micro"
29
-
30
-    override.vm.box = "dummy"
31
-    override.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
32
-    override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"]
33
-    override.ssh.username = ENV['AWS_SSH_USER'] || "ubuntu"
34
-
35
-    aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
36
-    aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
37
-    aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
38
-    aws.security_groups = [ ENV["AWS_SECURITY_GROUP"] ]
39
-  end
40
-end

+ 20 - 0
deployment/logrotate/huginn

@@ -0,0 +1,20 @@
1
+/home/huginn/huginn/log/*.log {
2
+  daily
3
+  missingok
4
+  rotate 180
5
+  # must use with delaycompress below
6
+  compress
7
+  dateext
8
+
9
+  # this is important if using "compress" since we need to call
10
+  # the "lastaction" script below before compressing:
11
+  delaycompress
12
+
13
+  # note the lack of the evil "copytruncate" option in this
14
+  # config.  Unicorn supports the USR1 signal and we send it
15
+  # as our "lastaction" action:
16
+  lastaction
17
+    pid=/home/huginn/huginn/tmp/pids/unicorn.pid
18
+    test -s $pid && kill -USR1 "$(cat $pid)"
19
+  endscript
20
+}

+ 70 - 0
deployment/nginx/huginn

@@ -0,0 +1,70 @@
1
+## Huginn
2
+##
3
+## Lines starting with two hashes (##) are comments with information.
4
+## Lines starting with one hash (#) are configuration parameters that can be uncommented.
5
+##
6
+###################################
7
+##         configuration         ##
8
+###################################
9
+##
10
+## See installation.md#using-https for additional HTTPS configuration details.
11
+
12
+upstream huginn {
13
+  server unix:/home/huginn/huginn/tmp/sockets/unicorn.socket fail_timeout=0;
14
+}
15
+
16
+## Normal HTTP host
17
+server {
18
+  listen 0.0.0.0:80 default_server;
19
+  listen [::]:80 ipv6only=on default_server;
20
+  server_name YOUR_SERVER_FQDN; ## Replace this with something like huginn.example.com
21
+  server_tokens off; ## Don't show the nginx version number, a security best practice
22
+  root /home/huginn/huginn/public;
23
+
24
+  ## Increase this if you want to upload large attachments
25
+  client_max_body_size 20m;
26
+
27
+  ## Individual nginx logs for this Huginn vhost
28
+  access_log  /var/log/nginx/huginn_access.log;
29
+  error_log   /var/log/nginx/huginn_error.log;
30
+
31
+  location / {
32
+    ## Serve static files from defined root folder.
33
+    ## @huginn is a named location for the upstream fallback, see below.
34
+    try_files $uri $uri/index.html $uri.html @huginn;
35
+  }
36
+
37
+  ## If a file, which is not found in the root folder is requested,
38
+  ## then the proxy passes the request to the upsteam (huginn unicorn).
39
+  location @huginn {
40
+    ## If you use HTTPS make sure you disable gzip compression
41
+    ## to be safe against BREACH attack.
42
+    # gzip off;
43
+
44
+    proxy_read_timeout      300;
45
+    proxy_connect_timeout   300;
46
+    proxy_redirect          off;
47
+
48
+    proxy_set_header    Host                $http_host;
49
+    proxy_set_header    X-Real-IP           $remote_addr;
50
+    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
51
+    proxy_set_header    X-Forwarded-Proto   $scheme;
52
+    proxy_set_header    X-Frame-Options     SAMEORIGIN;
53
+
54
+    proxy_pass http://huginn;
55
+  }
56
+
57
+  ## Enable gzip compression as per rails guide:
58
+  ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
59
+  ## WARNING: If you are using relative urls remove the block below
60
+  ## See config/application.rb under "Relative url support" for the list of
61
+  ## other files that need to be changed for relative url support
62
+  location ~ ^/(assets)/ {
63
+    root /home/huginn/huginn/public;
64
+    gzip_static on; # to serve pre-gzipped version
65
+    expires max;
66
+    add_header Cache-Control public;
67
+  }
68
+
69
+  error_page 502 /502.html;
70
+}

+ 119 - 0
deployment/nginx/huginn-ssl

@@ -0,0 +1,119 @@
1
+## Huginn
2
+##
3
+## Modified from nginx http version
4
+## Modified from http://blog.phusion.nl/2012/04/21/tutorial-setting-up-gitlab-on-debian-6/
5
+## Modified from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
6
+## Modified from https://github.com/gitlabhq/gitlabhq/blob/master/lib/support/nginx/gitlab-ssl
7
+##
8
+## Lines starting with two hashes (##) are comments with information.
9
+## Lines starting with one hash (#) are configuration parameters that can be uncommented.
10
+##
11
+###################################
12
+##         configuration         ##
13
+###################################
14
+##
15
+## See installation.md#using-https for additional HTTPS configuration details.
16
+
17
+upstream huginn {
18
+  server unix:/home/huginn/huginn/tmp/sockets/unicorn.socket fail_timeout=0;
19
+}
20
+
21
+## Redirects all HTTP traffic to the HTTPS host
22
+server {
23
+  listen 0.0.0.0:80;
24
+  listen [::]:80 ipv6only=on default_server;
25
+  server_name YOUR_SERVER_FQDN; ## Replace this with something like huginn.example.com
26
+  server_tokens off; ## Don't show the nginx version number, a security best practice
27
+  return 301 https://$server_name$request_uri;
28
+  access_log  /var/log/nginx/huginn_access.log;
29
+  error_log   /var/log/nginx/huginn_error.log;
30
+}
31
+
32
+
33
+## HTTPS host
34
+server {
35
+  listen 0.0.0.0:443 ssl;
36
+  listen [::]:443 ipv6only=on ssl default_server;
37
+  server_name YOUR_SERVER_FQDN; ## Replace this with something like huginn.example.com
38
+  server_tokens off; ## Don't show the nginx version number, a security best practice
39
+  root /home/git/huginn/public;
40
+
41
+  ## Increase this if you want to upload large attachments
42
+  ## Or if you want to accept large git objects over http
43
+  client_max_body_size 20m;
44
+
45
+  ## Strong SSL Security
46
+  ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html & https://cipherli.st/
47
+  ssl on;
48
+  ssl_certificate /etc/nginx/ssl/huginn.crt;
49
+  ssl_certificate_key /etc/nginx/ssl/huginn.key;
50
+
51
+  ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4';
52
+  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
53
+  ssl_prefer_server_ciphers on;
54
+  ssl_session_cache shared:SSL:10m;
55
+  ssl_session_timeout 5m;
56
+
57
+  ## See app/controllers/application_controller.rb for headers set
58
+
59
+  ## [Optional] If your certficate has OCSP, enable OCSP stapling to reduce the overhead and latency of running SSL.
60
+  ## Replace with your ssl_trusted_certificate. For more info see:
61
+  ## - https://medium.com/devops-programming/4445f4862461
62
+  ## - https://www.ruby-forum.com/topic/4419319
63
+  ## - https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx
64
+  # ssl_stapling on;
65
+  # ssl_stapling_verify on;
66
+  # ssl_trusted_certificate /etc/nginx/ssl/stapling.trusted.crt;
67
+  # resolver 208.67.222.222 208.67.222.220 valid=300s; # Can change to your DNS resolver if desired
68
+  # resolver_timeout 5s;
69
+
70
+  ## [Optional] Generate a stronger DHE parameter:
71
+  ##   sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096
72
+  ##
73
+  # ssl_dhparam /etc/ssl/certs/dhparam.pem;
74
+
75
+  ## Individual nginx logs for this huginn vhost
76
+  access_log  /var/log/nginx/huginn_access.log;
77
+  error_log   /var/log/nginx/huginn_error.log;
78
+
79
+  location / {
80
+    ## Serve static files from defined root folder.
81
+    ## @huginn is a named location for the upstream fallback, see below.
82
+    try_files $uri $uri/index.html $uri.html @huginn;
83
+  }
84
+
85
+  ## If a file, which is not found in the root folder is requested,
86
+  ## then the proxy passes the request to the upsteam (huginn unicorn).
87
+  location @huginn {
88
+    ## If you use HTTPS make sure you disable gzip compression
89
+    ## to be safe against BREACH attack.
90
+    gzip off;
91
+
92
+    proxy_read_timeout      300;
93
+    proxy_connect_timeout   300;
94
+    proxy_redirect          off;
95
+
96
+    proxy_set_header    Host                $http_host;
97
+    proxy_set_header    X-Real-IP           $remote_addr;
98
+    proxy_set_header    X-Forwarded-Ssl     on;
99
+    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
100
+    proxy_set_header    X-Forwarded-Proto   $scheme;
101
+    proxy_set_header    X-Frame-Options     SAMEORIGIN;
102
+
103
+    proxy_pass http://huginn;
104
+  }
105
+
106
+  ## Enable gzip compression as per rails guide:
107
+  ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
108
+  ## WARNING: If you are using relative urls remove the block below
109
+  ## See config/application.rb under "Relative url support" for the list of
110
+  ## other files that need to be changed for relative url support
111
+  location ~ ^/(assets)/ {
112
+    root /home/huginn/huginn/public;
113
+    gzip_static on; # to serve pre-gzipped version
114
+    expires max;
115
+    add_header Cache-Control public;
116
+  }
117
+
118
+  error_page 502 /502.html;
119
+}

+ 0 - 30
deployment/roles/huginn_development.json

@@ -1,30 +0,0 @@
1
-{
2
-
3
-"name" : "huginn_development",
4
-
5
-"chef_type" : "role",
6
-
7
-"json_class" : "Chef::Role",
8
-
9
-"description" : "Huginn Development Environment",
10
-
11
-"default_attributes" : {
12
-    "mysql" : {
13
-      "server_root_password" : "",
14
-      "server_repl_password" : "",
15
-      "server_debian_password" : ""
16
-    },
17
-    "nginx" : {
18
-       "init_style" : "upstart"
19
-    }
20
-},
21
-
22
-"run_list":[
23
-             "recipe[git]",
24
-             "recipe[apt]",
25
-             "recipe[mysql::server]",
26
-             "recipe[mysql::client]",
27
-             "recipe[nodejs::nodejs_from_binary]",
28
-             "recipe[huginn_development]"
29
-           ]
30
-}

+ 0 - 30
deployment/roles/huginn_production.json

@@ -1,30 +0,0 @@
1
-{
2
-
3
-"name" : "huginn_production",
4
-
5
-"chef_type" : "role",
6
-
7
-"json_class" : "Chef::Role",
8
-
9
-"description" : "Huginn Production Environment",
10
-
11
-"default_attributes" : {
12
-  "mysql": {
13
-    "server_root_password": "password",
14
-    "server_repl_password": "",
15
-    "server_debian_password": ""
16
-  },
17
-    "nginx" : {
18
-       "init_style" : "upstart"
19
-    }
20
-},
21
-
22
-"run_list":[
23
-             "recipe[git]",
24
-             "recipe[apt]",
25
-             "recipe[mysql::server]",
26
-             "recipe[nodejs::nodejs_from_binary]",
27
-             "recipe[nginx]",
28
-             "recipe[huginn_production]"
29
-           ]
30
-}

+ 0 - 78
deployment/site-cookbooks/huginn_development/recipes/default.rb

@@ -1,78 +0,0 @@
1
-include_recipe 'apt'
2
-include_recipe 'build-essential'
3
-
4
-user "huginn" do
5
-  action :create
6
-  system true
7
-  home "/home/huginn"
8
-  password "$6$ZwO6b.6tij$SMa8UIwtESGDxB37NwHsct.gJfXWmmflNbH.oypwJ9y0KkzMkCdw7D14iK7GX9C4CWSEcpGOFUow7p01rQFu5."
9
-  supports :manage_home => true
10
-  gid "sudo"
11
-  shell "/bin/bash"
12
-end
13
-
14
-group "huginn" do
15
-  members ["huginn"]
16
-  action :create
17
-end
18
-
19
-%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libmysqlclient-dev" "libffi-dev" "libssl-dev").each do |pkg|
20
-  package pkg do
21
-    action :install
22
-  end
23
-end
24
-
25
-bash "Setting default ruby and gem versions to 1.9" do
26
-  code <<-EOH
27
-    if [ $(readlink /usr/bin/ruby) != "ruby1.9.1" ]
28
-    then
29
-      update-alternatives --set ruby /usr/bin/ruby1.9.1
30
-    fi
31
-
32
-    if [ $(readlink /usr/bin/gem) != "gem1.9.1" ]
33
-    then
34
-      update-alternatives --set gem /usr/bin/gem1.9.1
35
-    fi
36
-  EOH
37
-end
38
-
39
-git "/home/huginn/huginn" do
40
-  repository 'git://github.com/cantino/huginn.git'
41
-  reference 'master'
42
-  action :sync
43
-  user "huginn"
44
-end
45
-
46
-gem_package("rake")
47
-gem_package("bundle")
48
-
49
-bash "Setting huginn user with NOPASSWD option" do
50
-  cwd "/etc/sudoers.d"
51
-  code <<-EOH
52
-    touch huginn
53
-    chmod 0440 huginn
54
-    echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
55
-    EOH
56
-end
57
-
58
-bash "huginn dependencies" do
59
-  user "huginn"
60
-  cwd "/home/huginn/huginn"
61
-  code <<-EOH
62
-    export LANG="en_US.UTF-8"
63
-    export LC_ALL="en_US.UTF-8"
64
-    sudo bundle install
65
-    sed s/REPLACE_ME_NOW\!/$(sudo bundle exec rake secret)/ .env.example > .env
66
-    sudo bundle exec rake db:create
67
-    sudo bundle exec rake db:migrate
68
-    sudo bundle exec rake db:seed
69
-    EOH
70
-end
71
-
72
-bash "huginn has been installed and will start in a minute" do
73
-  user "huginn"
74
-  cwd "/home/huginn/huginn"
75
-  code <<-EOH
76
-    sudo nohup foreman start &
77
-    EOH
78
-end

+ 0 - 2
deployment/site-cookbooks/huginn_production/files/default/Procfile

@@ -1,2 +0,0 @@
1
-web: sudo bundle exec unicorn_rails -c config/unicorn.rb -E production
2
-jobs: sudo RAILS_ENV=production bundle exec rails runner bin/threaded.rb

+ 0 - 110
deployment/site-cookbooks/huginn_production/files/default/env.example

@@ -1,110 +0,0 @@
1
-# ==== Required configuration settings for Huginn ====
2
-
3
-# Replace the following with the output from "rake secret"
4
-APP_SECRET_TOKEN=REPLACE_ME_NOW!
5
-
6
-# This is the domain where your Huginn instance will be running. The default should work
7
-# for development, but it needs to be changed to your Huginn domain when you deploy to a
8
-# production environment (e.g., yourdomain.com, possibly including a port).
9
-#DOMAIN=localhost:3000
10
-
11
-############################
12
-#      Database Setup      #
13
-############################
14
-
15
-DATABASE_ADAPTER=mysql2
16
-DATABASE_ENCODING=utf8
17
-DATABASE_RECONNECT=true
18
-DATABASE_NAME=huginn_production
19
-DATABASE_POOL=5
20
-DATABASE_USERNAME=root
21
-DATABASE_PASSWORD=password
22
-#DATABASE_HOST=your-domain-here.com
23
-#DATABASE_PORT=3306
24
-#DATABASE_SOCKET=/tmp/mysql.sock
25
-
26
-# ==== Additional required production settings ====
27
-
28
-# Configure Rails environment.  This should only be needed in production and may cause errors in development.
29
-RAILS_ENV=production
30
-
31
-# Should Rails force all requests to use SSL?
32
-FORCE_SSL=false
33
-
34
-############################
35
-#     Allowing Signups     #
36
-############################
37
-
38
-# This invitation code will be required for users to signup with your Huginn installation.
39
-# You can see its use in user.rb.  PLEASE CHANGE THIS!
40
-INVITATION_CODE=try-huginn
41
-
42
-# If you don't want to require users to have an invitation code, set this to true
43
-SKIP_INVITATION_CODE=false
44
-
45
-#############################
46
-#    Email Configuration    #
47
-#############################
48
-
49
-# Outgoing email settings.  To use Gmail or Google Apps, put your Google Apps domain or gmail.com
50
-# as the SMTP_DOMAIN and your Gmail username and password as the SMTP_USER_NAME and SMTP_PASSWORD.
51
-# 
52
-# PLEASE NOTE: In order to enable sending real emails via SMTP locally (e.g., when not in the production Rails environment),
53
-# you must also set SEND_EMAIL_IN_DEVELOPMENT to true below.
54
-
55
-SMTP_DOMAIN=your-domain-here.com
56
-SMTP_USER_NAME=you@gmail.com
57
-SMTP_PASSWORD=somepassword
58
-SMTP_SERVER=smtp.gmail.com
59
-SMTP_PORT=587
60
-SMTP_AUTHENTICATION=plain
61
-SMTP_ENABLE_STARTTLS_AUTO=true
62
-
63
-# Set to true to send real emails via SMTP when running in the development Rails environment.
64
-# Set to false to have emails intercepted in development and displayed at http://localhost:3000/letter_opener
65
-SEND_EMAIL_IN_DEVELOPMENT=false
66
-
67
-# The address from which system emails will appear to be sent.
68
-EMAIL_FROM_ADDRESS=from_address@gmail.com
69
-
70
-###########################
71
-#      Agent Logging      #
72
-###########################
73
-
74
-# Number of lines of log messages to keep per Agent
75
-AGENT_LOG_LENGTH=200
76
-
77
-#############################
78
-#  AWS and Mechanical Turk  #
79
-#############################
80
-
81
-# AWS Credentials for MTurk
82
-AWS_ACCESS_KEY_ID=YOUR-AWS-ACCESS-KEY-ID
83
-AWS_ACCESS_KEY=YOUR-AWS-ACCESS-KEY
84
-
85
-# Set AWS_SANDBOX to true if you're developing Huginn code.
86
-AWS_SANDBOX=false
87
-
88
-########################
89
-#   Various Settings   #
90
-########################
91
-
92
-# Specify the HTTP backend library for Faraday, used in WebsiteAgent.
93
-# You can change this depending on the performance and stability you
94
-# need for your service.  Any choice other than "typhoeus",
95
-# "net_http", or "em_http" should require you to bundle a corresponding
96
-# gem via Gemfile.
97
-FARADAY_HTTP_BACKEND=typhoeus
98
-
99
-# Allow JSONPath eval expresions. i.e., $..price[?(@ < 20)]
100
-# You should not allow this on a shared Huginn box because it is not secure.
101
-ALLOW_JSONPATH_EVAL=false
102
-
103
-# Enable this setting to allow insecure Agents like the ShellCommandAgent.  Only do this
104
-# when you trust everyone using your Huginn installation.
105
-ENABLE_INSECURE_AGENTS=false
106
-
107
-# Use Graphviz for generating diagrams instead of using Google Chart
108
-# Tools.  Specify a dot(1) command path built with SVG support
109
-# enabled.
110
-#USE_GRAPHVIZ_DOT=dot

+ 0 - 36
deployment/site-cookbooks/huginn_production/files/default/nginx.conf

@@ -1,36 +0,0 @@
1
-#worker_process 2;
2
-user huginn huginn;
3
-
4
-events {
5
-  worker_connections 1024;
6
-  accept_mutex on;
7
-}
8
-
9
-http {
10
-  types_hash_max_size 2048;
11
-  include    mime.types;
12
-
13
-  upstream huginn_server {
14
-    server unix:/home/huginn/shared/tmp/sockets/unicorn.sock;
15
-  }
16
-
17
-  server {
18
-    listen 80;
19
-    server_name _;
20
-    keepalive_timeout 5;
21
-    root /home/huginn/current/public;
22
-    try_files $uri/index.html $uri.html $uri @app;
23
-    error_page 500 502 503 504 /500.html;
24
-    location = /500.html {
25
-      root /home/huginn/current/public;
26
-    }
27
-    location @app {
28
-      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29
-      proxy_set_header X-Forwarded-Proto $scheme;
30
-      proxy_set_header Host $http_host;
31
-      proxy_redirect off;
32
-      proxy_pass http://huginn_server;
33
-    }
34
-}
35
-}
36
-

+ 0 - 111
deployment/site-cookbooks/huginn_production/recipes/default.rb

@@ -1,111 +0,0 @@
1
-include_recipe 'apt'
2
-include_recipe 'build-essential'
3
-
4
-user "huginn" do
5
-  system true
6
-  home "/home/huginn"
7
-  password "$6$ZwO6b.6tij$SMa8UIwtESGDxB37NwHsct.gJfXWmmflNbH.oypwJ9y0KkzMkCdw7D14iK7GX9C4CWSEcpGOFUow7p01rQFu5."
8
-  supports :manage_home => true
9
-  shell "/bin/bash"
10
-  gid "sudo"
11
-end
12
-
13
-group "huginn" do
14
-  members ["huginn"]
15
-end
16
-
17
-%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libmysqlclient-dev" "libffi-dev" "libssl-dev").each do |pkg|
18
-  package("#{pkg}")
19
-end
20
-
21
-bash "Setting default ruby and gem versions to 1.9" do
22
-  code <<-EOH
23
-    if [ $(readlink /usr/bin/ruby) != "ruby1.9.1" ]
24
-    then
25
-      update-alternatives --set ruby /usr/bin/ruby1.9.1
26
-    fi
27
-
28
-    if [ $(readlink /usr/bin/gem) != "gem1.9.1" ]
29
-    then
30
-      update-alternatives --set gem /usr/bin/gem1.9.1
31
-    fi
32
-  EOH
33
-end
34
-
35
-gem_package("rake")
36
-gem_package("bundle")
37
-
38
-service "nginx" do
39
-  supports :restart => true, :start => true, :stop => true, :reload => true
40
-  action :nothing
41
-end
42
-
43
-bash "Setting huginn user with NOPASSWD option" do
44
-  cwd "/etc/sudoers.d"
45
-  code <<-EOH
46
-    touch huginn && chmod 0440 huginn 
47
-    echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
48
-  EOH
49
-end
50
-
51
-deploy "/home/huginn" do
52
-  repo "https://github.com/cantino/huginn.git"
53
-  branch "master"
54
-  user "huginn"
55
-  group "huginn"
56
-  environment "RAILS_ENV" => "production"
57
-  keep_releases 5
58
-  create_dirs_before_symlink []
59
-  symlinks "log" => "log"
60
-  symlink_before_migrate({})
61
-  rollback_on_error true
62
-  notifies :enable, "service[nginx]"
63
-  notifies :start, "service[nginx]"
64
-  before_symlink do
65
-    %w(config log tmp).each do |dir|
66
-      directory "/home/huginn/shared/#{dir}" do
67
-      owner "huginn"
68
-      group "huginn"
69
-      recursive true
70
-      end
71
-    end
72
-    directory("/home/huginn/shared/tmp/pids")
73
-    directory("/home/huginn/shared/tmp/sockets")
74
-    %w(Procfile unicorn.rb nginx.conf).each do |file|
75
-      cookbook_file "/home/huginn/shared/config/#{file}" do
76
-      owner "huginn"
77
-      action :create_if_missing
78
-      end
79
-    end
80
-    cookbook_file "home/huginn/shared/config/.env" do
81
-    source "env.example"
82
-    mode "666"
83
-    owner "huginn"
84
-    action :create_if_missing
85
-    end
86
-  end
87
-  before_restart do
88
-    bash "huginn dependencies" do
89
-      cwd "/home/huginn/current"
90
-      user "huginn"
91
-      group "huginn"
92
-      code <<-EOH
93
-      export LANG="en_US.UTF-8"
94
-      export LC_ALL="en_US.UTF-8"
95
-      ln -nfs /home/huginn/shared/config/Procfile ./Procfile
96
-      ln -nfs /home/huginn/shared/config/.env ./.env
97
-      ln -nfs /home/huginn/shared/config/unicorn.rb ./config/unicorn.rb
98
-      sudo cp /home/huginn/shared/config/nginx.conf /etc/nginx/
99
-      echo 'gem "unicorn", :group => :production' >> Gemfile
100
-      sudo bundle install --without=development --without=test
101
-      sed -i s/REPLACE_ME_NOW\!/$(sudo bundle exec rake secret)/ /home/huginn/shared/config/.env
102
-      sudo RAILS_ENV=production bundle exec rake db:create
103
-      sudo RAILS_ENV=production bundle exec rake db:migrate
104
-      sudo RAILS_ENV=production bundle exec rake db:seed
105
-      sudo RAILS_ENV=production bundle exec rake assets:precompile
106
-      sudo foreman export upstart /etc/init -a huginn -u huginn -l log
107
-      sudo start huginn
108
-      EOH
109
-    end
110
-  end
111
-end

+ 20 - 0
doc/README.md

@@ -0,0 +1,20 @@
1
+# Documentation
2
+
3
+## Installation and upgrading
4
+
5
+### Docker (not recommended for production)
6
+
7
+- [Check out Huginn with Docker](docker/install.md) Run a local Huginn installation using Docker
8
+
9
+### Manual installation
10
+
11
+Manual installation instructions which will guide through the steps to install Huginn on any Ubuntu 12.04/14.04 or Debian 6/7 server.
12
+
13
+- [Install](manual/README.md) Requirements, directory structures and installation from source.
14
+- [Update](manual/update.md) Update your installation.
15
+- Deploy updates via [Capistrano](manual/capistrano.md).
16
+
17
+### Heroku
18
+
19
+- [Deploy to Heroku](heroku/install.md)
20
+- [Update](heroku/update.md) an existing Heroku deployment

deployment/nodes/.gitignore → doc/configuration/dotenv.md


+ 0 - 0
doc/configuration/procfile.md


+ 44 - 0
doc/docker/install.md

@@ -0,0 +1,44 @@
1
+## Why run Huginn with docker
2
+
3
+You can play with or deploy Huginn inside of [docker](http://www.docker.io/).
4
+
5
+Getting Huginn up and running using docker is quick and painless once you have docker installed. The docker container is suitable for production and evaluation. Huginn uses environmental variables for configuration, so rather than having a .env file, the Docker container expects variables to be passed into the launch command.
6
+
7
+## Running the Container
8
+
9
+### Quick start to check out Huginn
10
+
11
+#### OSX GUI using Kitematic
12
+
13
+1. Download and install [Kitematic](https://www.docker.com/docker-kitematic)
14
+* Start Kitematic and search for `cantino/huginn`
15
+* Click `create` and wait for the container to be downloaded and booted
16
+* Click on the link icon next to 'WEB PREVIEW'
17
+* Log in to your Huginn instance using the username `admin` and password `password`
18
+
19
+#### OSX/Windows/Linux using docker machine
20
+
21
+1. Download [docker machine](https://docs.docker.com/machine/#installation) for your OS
22
+* Follow the installation instructions untill you can successfully run `docker ps`
23
+* Get the the IP of the VM running docker by running `docker-machine ls`
24
+* Start your Huginn container using `docker run -it -p 3000:3000 cantino/huginn`
25
+* Open Huginn in the browser [http://docker-machine ip:3000](http://<docker-machine ip>:3000)
26
+* Log in to your Huginn instance using the username `admin` and password `password`
27
+
28
+#### Linux
29
+
30
+1. Install docker using the [install instructions](https://docs.docker.com/installation/)
31
+* Start your Huginn container using `docker run -it -p 3000:3000 cantino/huginn`
32
+* Open Huginn in the browser [http://localhost:3000](http://localhost:3000)
33
+* Log in to your Huginn instance using the username `admin` and password `password`
34
+
35
+## Configuration and linking to a database container
36
+
37
+Follow the [instructions on the docker hub registry](https://registry.hub.docker.com/u/cantino/huginn/) on how to configure Huginn using environment variables and linking the container to an external MySQL or PostgreSQL database.
38
+
39
+### Other options:
40
+
41
+Other Docker options:
42
+
43
+* If you don't want to use the official repo, see also: https://registry.hub.docker.com/u/andrewcurioso/huginn/
44
+* If you'd like to run Huginn's web process and job worker process in separate containers, another option is https://github.com/hackedu/huginn-docker. It also uses Unicorn as the web server and serves precompiled assets.

+ 144 - 0
doc/heroku/install.md

@@ -0,0 +1,144 @@
1
+## Deploy to Heroku
2
+
3
+### Important things to keep in mind on the free plan
4
+
5
+* Heroku's [free plan](https://www.heroku.com/pricing) limits total runtime per day to 18 hours. This means that Huginn must sleep some of the time, and so recurring tasks will only run if their recurrence frequency fits within the free plan's awake time, which is 30 minutes. Therefore, we recommend that you only use the every 1 minute, every 2 minute, and every 5 minute Agent scheduling options.
6
+* When setting up Pingdom, set the `Check interval` to '60 minutes' so that your Huginn instance is up half the time.
7
+* Heroku's free Postgres plan limits the number of database rows that you can have to 10,000, so you should be sure to set a low event retention schedule for your agents.
8
+* The `setup_heroku` command points Heroku at a special Procfile (`deployment/heroku/Procfile.heroku`) that is designed to be run on only one Heroku web worker.  If you want to run multiple workers, change the Heroku config variable `PROCFILE_PATH` with `heroku config:set PROCFILE_PATH=./Procfile` and switch back to the standard Huginn Procfile configuration.
9
+
10
+### Instructions
11
+
12
+* Install the [Heroku Toolbelt](https://toolbelt.heroku.com/) and then run `heroku login`
13
+* Go into your huginn directory and run `bundle`
14
+* Now, run the magic setup wizard: `bin/setup_heroku`
15
+* That's it!
16
+* If you make changes, you can re-run `bin/setup_heroku`, or just do `git push heroku master`.
17
+* Signup for a free [Pingdom](https://www.pingdom.com/free/) account and have it ping your Huginn URL on Heroku once an hour.
18
+
19
+### Using your own mail server
20
+
21
+```bash
22
+# Outgoing email settings.  To use Gmail or Google Apps, put your Google Apps domain or gmail.com
23
+# as the SMTP_DOMAIN and your Gmail username and password as the SMTP_USER_NAME and SMTP_PASSWORD.
24
+heroku config:set SMTP_DOMAIN=your-domain-here.com
25
+heroku config:set SMTP_USER_NAME=you@gmail.com
26
+heroku config:set SMTP_PASSWORD=somepassword
27
+heroku config:set SMTP_SERVER=smtp.gmail.com
28
+
29
+# The address from which system emails will appear to be sent.
30
+heroku config:set EMAIL_FROM_ADDRESS=you@gmail.com
31
+```
32
+
33
+### Backing up your data
34
+
35
+See: https://devcenter.heroku.com/articles/heroku-postgres-import-export
36
+
37
+### Example output from `bin/setup_heroku`
38
+
39
+```
40
+~/projects/oss/huginn (master)$ bin/setup_heroku 
41
+
42
+Welcome andrew@example.com!  It looks like you're logged into Heroku.
43
+
44
+It looks like you don't have a Heroku app set up yet for this repo.
45
+You can either exit now and run 'heroku create', or I can do it for you.
46
+Would you like me to create a Heroku app for you now in this repo? (y/n) y
47
+Creating radiant-forest-1519... done, stack is cedar
48
+http://radiant-forest-1519.herokuapp.com/ | git@heroku.com:radiant-forest-1519.git
49
+Git remote heroku added
50
+Your Heroku app name is radiant-forest-1519.  Is this correct? (y/n) y
51
+Setting up APP_SECRET_TOKEN...
52
+Setting BUILDPACK_URL to https://github.com/ddollar/heroku-buildpack-multi.git
53
+BUILDPACK_URL: https://github.com/ddollar/heroku-buildpack-multi.git
54
+Setting PROCFILE_PATH to deployment/heroku/Procfile.heroku
55
+PROCFILE_PATH: deployment/heroku/Procfile.heroku
56
+Setting ON_HEROKU to true
57
+Setting FORCE_SSL to true
58
+Setting DOMAIN to radiant-forest-1519.herokuapp.com
59
+
60
+You need to set an invitation code for your Huginn instance.  If you plan to share this instance, you will
61
+tell this code to anyone who you'd like to invite.  If you won't share it, then just set this to something
62
+that people will not guess.
63
+What code would you like to use? 
64
+What code would you like to use? something-secret
65
+Setting INVITATION_CODE to something-secret
66
+
67
+Okay, let's setup outgoing email settings.  The simplest solution is to use the free sendgrid Heroku addon.
68
+If you'd like to use your own server, or your Gmail account, please see .env.example and set
69
+SMTP_DOMAIN, SMTP_USER_NAME, SMTP_PASSWORD, and SMTP_SERVER with 'heroku config:set'.
70
+Should I enable the free sendgrid addon? (y/n) y
71
+Use `heroku addons:docs sendgrid` to view documentation.
72
+SMTP_SERVER: smtp.sendgrid.net
73
+SMTP_DOMAIN: heroku.com
74
+SMTP_USER_NAME: app27830035@heroku.com
75
+SMTP_PASSWORD: sflajgz0
76
+What email address would you like email to appear to be sent from? andrew@example.com
77
+Setting EMAIL_FROM_ADDRESS to andrew@example.com
78
+EMAIL_FROM_ADDRESS: andrew@example.com
79
+
80
+Should I push your current branch (master) to heroku? (y/n) y
81
+This may take a moment...
82
+Initializing repository, done.
83
+
84
+-----> Fetching custom git buildpack... done
85
+-----> Multipack app detected
86
+=====> Downloading Buildpack: https://github.com/cantino/heroku-selectable-procfile.git
87
+=====> Detected Framework: Selectable Procfile
88
+-----> Using deployment/heroku/Procfile.heroku as Procfile
89
+=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-ruby.git
90
+=====> Detected Framework: Ruby
91
+-----> Compiling Ruby/Rails
92
+-----> Using Ruby version: ruby-2.0.0
93
+-----> Installing dependencies using 1.6.3
94
+       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
95
+       Fetching source index from https://rubygems.org/
96
+       Fetching git://github.com/cantino/twitter-stream.git
97
+       Installing i18n 0.6.9
98
+       Installing rake 10.3.2
99
+       Installing minitest 5.3.5
100
+       [...gems are installed...]
101
+       Your bundle is complete!
102
+       Gems in the groups development and test were not installed.
103
+       It was installed into ./vendor/bundle
104
+       Post-install message from httparty:
105
+       When you HTTParty, you must party hard!
106
+       Post-install message from rufus-scheduler:
107
+       Bundle completed (133.85s)
108
+       Cleaning up the bundler cache.
109
+-----> Preparing app for Rails asset pipeline
110
+       Running: rake assets:precompile
111
+       I, [2014-07-26T20:36:06.069156 #5939]  INFO -- : Writing /tmp/build_7b0d30bd-3c35-46dc-b73d-b5f05754d340/public/assets/select2x2-ec4bf2b76c97838b357413d72a2f69cf.png [...]
112
+       Asset precompilation completed (42.28s)
113
+       Cleaning assets
114
+       Running: rake assets:clean
115
+
116
+Using release configuration from last framework (Ruby).
117
+-----> Discovering process types
118
+       Procfile declares types     -> web
119
+       Default types for Multipack -> console, rake, worker
120
+
121
+-----> Compressing... done, 45.1MB
122
+-----> Launching... done, v19
123
+       http://radiant-forest-1519.herokuapp.com/ deployed to Heroku
124
+
125
+To git@heroku.com:radiant-forest-1519.git
126
+ * [new branch]      master -> master
127
+Running database migrations...
128
+Running `rake db:migrate` attached to terminal... up, run.3341
129
+
130
+[...migrations run...]
131
+
132
+I can make an admin user on your new Huginn instance and setup some example Agents.
133
+Should I create a new admin user and some example Agents? (y/n) y
134
+
135
+Okay, what is your email address? andrew@example.com
136
+And what username would you like to login as? andrew
137
+Finally, what password would you like to use? 
138
+Just a moment...
139
+
140
+
141
+Okay, you should be all set!  Visit https://radiant-forest-1519.herokuapp.com and login as 'andrew' with your password.
142
+
143
+Done!
144
+```

+ 9 - 0
doc/heroku/update.md

@@ -0,0 +1,9 @@
1
+## Update an existing Heroku deployment
2
+
3
+Once you've run `bin/setup_heroku`, you should have 'cantino/huginn' as a remote in git.  (Check with `git remote -v`.)  Now, you can update your Heroku installation with the following commands:
4
+
5
+```sh
6
+git fetch origin
7
+git merge origin/master
8
+git push -f heroku master # note: this will wipe out any code changes that only exist on Heroku!
9
+```

+ 6 - 0
doc/manual/README.md

@@ -0,0 +1,6 @@
1
+# Manual Installation
2
+
3
+- [Requirements](requirements.md) Software and hardware requirements to run the Huginn installation
4
+- [Install](installation.md) Installation guide for Ubundu/Debian
5
+- [Update](update.md) Update an existing Huginn installation
6
+- Deploy updates via [Capistrano](capistrano.md)

+ 47 - 0
doc/manual/capistrano.md

@@ -0,0 +1,47 @@
1
+# Deploy updates via Capistrano
2
+
3
+After you followed the [manual installation guide](installation.md) it is simple to push updates to your huginn instance using capistrano.
4
+
5
+### 1. Ensure you have SSH access to your server via the huginn user
6
+
7
+Either set a password for the huginn user or add your public SSH key:
8
+
9
+    # Set password
10
+    sudo passwd huginn
11
+
12
+    # Or add a SSH key
13
+    sudo -u huginn -H mkdir -p /home/huginn/.ssh
14
+    sudo -u huginn -H editor /home/huginn/.ssh/authorized_keys
15
+    sudo -u huginn -H chmod -R 700 /home/huginn/.ssh
16
+
17
+### 2. Configure Capistrano on your local machine
18
+
19
+Add Capistrano configuration to you local `.env`:
20
+
21
+    CAPISTRANO_DEPLOY_SERVER=<IP or FQDN of your server>
22
+    CAPISTRANO_DEPLOY_USER=huginn
23
+    CAPISTRANO_DEPLOY_REPO_URL=https://github.com/cantino/huginn.git
24
+
25
+
26
+### 3. Run Capistrano
27
+
28
+You can now run Capistrano and update your server:
29
+
30
+    cap production deploy
31
+
32
+If you want to deploy a different branch, pass it as environment variable:
33
+
34
+    cap production deploy BRANCH=awesome-feature
35
+
36
+### Changes to remote .env and Procfile
37
+
38
+If you want to change the `.env`, `Procfile` or `config/unicorn.rb` of your installation you still need to do it on your server, do not forget to export the init scripts after your are done:
39
+
40
+    cd /home/huginn/huginn
41
+    # Whichever you want to change
42
+    sudo -u huginn -H editor Procfile
43
+    sudo -u huginn -H editor .env
44
+    sudo -u huginn -H editor config/unicorn.rb
45
+    # Export init scripts and restart huginn
46
+    sudo rake production:export
47
+

+ 401 - 0
doc/manual/installation.md

@@ -0,0 +1,401 @@
1
+# Installation from source
2
+
3
+
4
+## Important Notes
5
+
6
+This guide is long because it covers many cases and includes all commands you need.
7
+
8
+This installation guide was created for and tested on **Debian/Ubuntu** operating systems. Please read [doc/install/requirements.md](./requirements.md) for hardware and operating system requirements.
9
+
10
+This is the official installation guide to set up a production server. To set up a **development installation** or for many other installation options please see [the getting started section of the readme](https://github.com/cantino/huginn#getting-started).
11
+
12
+The following steps have been known to work. Please **use caution when you deviate** from this guide. Make sure you don't violate any assumptions Huginn makes about its environment. For example many people run into permission problems because they change the location of directories or run services as the wrong user.
13
+
14
+If you find a bug/error in this guide please **submit a pull request**.
15
+
16
+If not stated otherwise all commands should be run as user with sudo permissions or as root.
17
+
18
+When having problems during the installation please check the [troubleshooting](#troubleshooting) section.
19
+
20
+## Overview
21
+
22
+The Huginn installation consists of setting up the following components:
23
+
24
+1. Packages / Dependencies
25
+1. Ruby
26
+1. System Users
27
+1. Database
28
+1. Huginn
29
+1. Nginx
30
+
31
+## 1. Packages / Dependencies
32
+
33
+`sudo` is not installed on Debian by default. Make sure your system is
34
+up-to-date and install it.
35
+
36
+    # run as root!
37
+    apt-get update -y
38
+    apt-get upgrade -y
39
+    apt-get install sudo -y
40
+
41
+**Note:** During this installation some files will need to be edited manually. If you are familiar with vim set it as default editor with the commands below. If you are not familiar with vim please skip this and keep using the default editor.
42
+
43
+    # Install vim and set as default editor
44
+    sudo apt-get install -y vim
45
+    sudo update-alternatives --set editor /usr/bin/vim.basic
46
+
47
+Import node.js repository (can be skipped on Ubuntu and Debian Jessie):
48
+
49
+    curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
50
+
51
+Install the required packages (needed to compile Ruby and native extensions to Ruby gems):
52
+
53
+    sudo apt-get install -y runit build-essential git zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake nodejs graphviz
54
+
55
+
56
+## 2. Ruby
57
+
58
+
59
+The use of Ruby version managers such as [RVM](http://rvm.io/), [rbenv](https://github.com/sstephenson/rbenv) or [chruby](https://github.com/postmodern/chruby) with Huginn in production frequently leads to hard-to-diagnose problems. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system Ruby.
60
+
61
+Remove the old Ruby versions if present:
62
+
63
+    sudo apt-get remove -y ruby1.8 ruby1.9
64
+
65
+Download Ruby and compile it:
66
+
67
+    mkdir /tmp/ruby && cd /tmp/ruby
68
+    curl -L --progress http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.bz2 | tar xj
69
+    cd ruby-2.2.3
70
+    ./configure --disable-install-rdoc
71
+    make -j`nproc`
72
+    sudo make install
73
+
74
+Install the bundler and foreman gems:
75
+
76
+    sudo gem install bundler foreman --no-ri --no-rdoc
77
+
78
+## 3. System Users
79
+
80
+Create a user for Huginn:
81
+
82
+    sudo adduser --disabled-login --gecos 'Huginn' huginn
83
+
84
+## 4. Database
85
+
86
+Install the database packages
87
+
88
+    sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
89
+
90
+    # Pick a MySQL root password (can be anything), type it and press enter,
91
+    # retype the MySQL root password and press enter
92
+
93
+Check the installed MySQL version (remeber if its >= 5.5.3 for the `.env` configuration done later):
94
+
95
+    mysql --version
96
+
97
+Secure your installation
98
+
99
+    sudo mysql_secure_installation
100
+
101
+Login to MySQL
102
+
103
+    mysql -u root -p
104
+
105
+    # Type the MySQL root password
106
+
107
+Create a user for Huginn do not type the `mysql>`, this is part of the prompt. Change `$password` in the command below to a real password you pick
108
+
109
+    mysql> CREATE USER 'huginn'@'localhost' IDENTIFIED BY '$password';
110
+
111
+Ensure you can use the InnoDB engine which is necessary to support long indexes
112
+
113
+    mysql> SET storage_engine=INNODB;
114
+
115
+    # If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`)
116
+    # for the setting "innodb = off"
117
+
118
+Grant the Huginn user necessary permissions on the database
119
+
120
+    mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `huginn_production`.* TO 'huginn'@'localhost';
121
+
122
+Quit the database session
123
+
124
+    mysql> \q
125
+
126
+Try connecting to the new database with the new user
127
+
128
+    sudo -u huginn -H mysql -u huginn -p -D huginn_production
129
+
130
+    # Type the password you replaced $password with earlier
131
+
132
+You should now see `ERROR 1049 (42000): Unknown database 'huginn_production'` which is fine because we will create the database later.
133
+
134
+You are done installing the database and can go back to the rest of the installation.
135
+
136
+
137
+## 6. Huginn
138
+
139
+### Clone the Source
140
+
141
+    # We'll install Huginn into the home directory of the user "huginn"
142
+    cd /home/huginn
143
+
144
+    # Clone Huginn repository
145
+    sudo -u huginn -H git clone https://github.com/cantino/huginn.git -b master huginn
146
+
147
+    # Go to Huginn installation folder
148
+    cd /home/huginn/huginn
149
+
150
+    # Copy the example Huginn config
151
+    sudo -u huginn -H cp .env.example .env
152
+
153
+    # Create the log/, tmp/pids/ and tmp/sockets/ directories
154
+    sudo -u huginn mkdir -p log tmp/pids tmp/sockets
155
+
156
+    # Make sure Huginn can write to the log/ and tmp/ directories
157
+    sudo chown -R huginn log/ tmp/
158
+    sudo chmod -R u+rwX,go-w log/ tmp/
159
+
160
+    # Make sure permissions are set correctly
161
+    sudo chmod -R u+rwX,go-w log/
162
+    sudo chmod -R u+rwX tmp/
163
+    sudo -u huginn -H chmod o-rwx .env
164
+
165
+    # Copy the example Unicorn config
166
+    sudo -u huginn -H cp config/unicorn.rb.example config/unicorn.rb
167
+
168
+### Install Gems
169
+
170
+**Note:** As of bundler 1.5.2, you can invoke `bundle install -jN` (where `N` the number of your processor cores) and enjoy parallel gem installation with measurable difference in completion time (~60% faster). Check the number of your cores with `nproc`. For more information check this [post](http://robots.thoughtbot.com/parallel-gem-installing-using-bundler). First make sure you have bundler >= 1.5.2 (run `bundle -v`) as it addresses some [issues](https://devcenter.heroku.com/changelog-items/411) that were [fixed](https://github.com/bundler/bundler/pull/2817) in 1.5.2.
171
+
172
+    sudo -u huginn -H bundle install --deployment --without development test
173
+
174
+
175
+### Configure it
176
+
177
+    # Update Huginn config file and follow the instructions
178
+    sudo -u huginn -H editor .env
179
+
180
+If you are using a local MySQL server the database configuration should look like this (use the password of the huginn MySQL user you created earlier):
181
+
182
+    DATABASE_ADAPTER=mysql2
183
+    DATABASE_RECONNECT=true
184
+    DATABASE_NAME=huginn_production
185
+    DATABASE_POOL=20
186
+    DATABASE_USERNAME=huginn
187
+    DATABASE_PASSWORD='$password'
188
+    #DATABASE_HOST=your-domain-here.com
189
+    #DATABASE_PORT=3306
190
+    #DATABASE_SOCKET=/tmp/mysql.sock
191
+
192
+    DATABASE_ENCODING=utf8
193
+    # MySQL only: If you are running a MySQL server >=5.5.3, you should
194
+    # set DATABASE_ENCODING to utf8mb4 instead of utf8 so that the
195
+    # database can hold 4-byte UTF-8 characters like emoji.
196
+    #DATABASE_ENCODING=utf8mb4
197
+
198
+**Important**: Uncomment the RAILS_ENV setting to run Huginn in the production rails environment
199
+
200
+    RAILS_ENV=production
201
+
202
+Change the Unicorn config if needed, the [requirements.md](./requirements.md#unicorn-workers) has a section explaining the suggested amount of unicorn workers:
203
+
204
+    # Increase the amount of workers if you expect to have a high load instance.
205
+    # 2 are enough for most use cases, if the server has less then 2GB of RAM
206
+    # decrease the worker amount to 1
207
+    sudo -u huginn -H editor config/unicorn.rb
208
+
209
+
210
+**Important Note:** Make sure to edit both `.env` and `unicorn.rb` to match your setup.
211
+
212
+**Note:** If you want to use HTTPS, which is what we recommend, see [Using HTTPS](#using-https) for the additional steps.
213
+
214
+
215
+### Initialize Database
216
+
217
+    # Create the database
218
+    sudo -u huginn -H bundle exec rake db:create RAILS_ENV=production
219
+
220
+    # Migrate to the latest version
221
+    sudo -u huginn -H bundle exec rake db:migrate RAILS_ENV=production
222
+
223
+    # Create admin user and example agents
224
+    sudo -u huginn -H bundle exec rake db:seed RAILS_ENV=production
225
+
226
+When done you see `See the Huginn Wiki for more Agent examples!  https://github.com/cantino/huginn/wiki`
227
+
228
+**Note:** This will create an initial user, you can set the username and password by supplying it in environmental variables `SEED_USERNAME` and `SEED_PASSWORD` as seen below. If you don't set the password (and it is set to the default one) please wait with exposing Huginn to the public internet until the installation is done and you've logged into the server and changed your password.
229
+
230
+    sudo -u huginn -H bundle exec rake db:seed RAILS_ENV=production SEED_USERNAME=admin SEED_PASSWORD=yourpassword
231
+
232
+### Compile Assets
233
+
234
+    sudo -u huginn -H bundle exec rake assets:precompile RAILS_ENV=production
235
+
236
+### Install Init Script
237
+
238
+Huginn uses [foreman](http://ddollar.github.io/foreman/) to generate the init scripts based on a `Procfile`
239
+
240
+Edit the `Procfile` and choose one of the suggested versions for production
241
+
242
+    sudo -u huginn -H editor Procfile
243
+
244
+Export the init scripts:
245
+
246
+    sudo rake production:export
247
+
248
+**Note:** You have to re-export the init script every time you change the configuration in `.env` or your `Procfile`!
249
+
250
+### Setup Logrotate
251
+
252
+    sudo cp deployment/logrotate/huginn /etc/logrotate.d/huginn
253
+
254
+
255
+### Ensure Your Huginn Instance Is Running
256
+
257
+    sudo rake production:status
258
+
259
+## 7. Nginx
260
+
261
+**Note:** Nginx is the officially supported web server for Huginn. If you cannot or do not want to use Nginx as your web server, the wiki has a page on how to configure [apache](https://github.com/cantino/huginn/wiki/Apache-Huginn-configuration).
262
+
263
+### Installation
264
+
265
+    sudo apt-get install -y nginx
266
+
267
+### Site Configuration
268
+
269
+Copy the example site config:
270
+
271
+    sudo cp deployment/nginx/huginn /etc/nginx/sites-available/huginn
272
+    sudo ln -s /etc/nginx/sites-available/huginn /etc/nginx/sites-enabled/huginn
273
+
274
+Make sure to edit the config file to match your setup, if you are running multiple nginx sites remove the `default_server` argument from the `listen` directives:
275
+
276
+    # Change YOUR_SERVER_FQDN to the fully-qualified
277
+    # domain name of your host serving Huginn.
278
+    sudo editor /etc/nginx/sites-available/huginn
279
+
280
+Remove the default nginx site, **if huginn is the only enabled nginx site**:
281
+
282
+    sudo rm /etc/nginx/sites-enabled/default
283
+
284
+**Note:** If you want to use HTTPS, which is what we recommend, replace the `huginn` Nginx config with `huginn-ssl`. See [Using HTTPS](#using-https) for HTTPS configuration details.
285
+
286
+### Test Configuration
287
+
288
+Validate your `huginn` or `huginn-ssl` Nginx config file with the following command:
289
+
290
+    sudo nginx -t
291
+
292
+You should receive `syntax is okay` and `test is successful` messages. If you receive errors check your `huginn` or `huginn-ssl` Nginx config file for typos, etc. as indicated in the error message given.
293
+
294
+### Restart
295
+
296
+    sudo service nginx restart
297
+
298
+# Done!
299
+
300
+### Initial Login
301
+
302
+Visit YOUR_SERVER in your web browser for your first Huginn login. The setup has created a default admin account for you. You can use it to log in:
303
+
304
+    admin
305
+    password
306
+
307
+
308
+**Enjoy!** :sparkles: :star: :fireworks:
309
+
310
+You can use `cd /home/huginn/huginn && sudo rake production:start` and `cd /home/huginn/huginn && sudo rake production:stop` to start and stop Huginn.
311
+
312
+Be sure to read the section about how to [update](./update.md) your Huginn installation as well! You can also use [Capistrano](./capistrano.md) to keep your installation up to date.
313
+
314
+**Note:** We also recommend applying standard security practices to your server, including installing a firewall ([ufw](https://wiki.ubuntu.com/UncomplicatedFirewall) is good on Ubuntu and also available for Debian).
315
+
316
+## Advanced Setup Tips
317
+
318
+### Using HTTPS
319
+
320
+To use Huginn with HTTPS:
321
+
322
+1. In `.env`:
323
+    1. Set the `FORCE_SSL` option to `true`.
324
+1. Use the `huginn-ssl` Nginx example config instead of the `huginn` config:
325
+    1. `sudo cp deployment/nginx/huginn-ssl /etc/nginx/sites-available/huginn`
326
+    1. Update `YOUR_SERVER_FQDN`.
327
+    1. Update `ssl_certificate` and `ssl_certificate_key`.
328
+    1. Review the configuration file and consider applying other security and performance enhancing features.
329
+
330
+Restart Nginx, export the init script and restart Huginn:
331
+
332
+```
333
+cd /home/huginn/huginn
334
+sudo service nginx restart
335
+sudo rake production:export
336
+```
337
+
338
+Using a self-signed certificate is discouraged, but if you must use it follow the normal directions. Then generate the certificate:
339
+
340
+```
341
+sudo mkdir -p /etc/nginx/ssl/
342
+cd /etc/nginx/ssl/
343
+sudo openssl req -newkey rsa:2048 -x509 -nodes -days 3560 -out huginn.crt -keyout huginn.key
344
+sudo chmod o-r huginn.key
345
+```
346
+
347
+## Troubleshooting
348
+
349
+If something went wrong during the installation please make sure you followed the instructions and did not miss a step.
350
+
351
+When your Huginn instance still is not working first run the self check:
352
+
353
+    cd /home/huginn/huginn
354
+    sudo rake production:check
355
+
356
+We are sorry when you are still having issues, now please check the various log files for error messages:
357
+
358
+#### Nginx error log `/var/log/nginx/huginn_error.log`
359
+
360
+This file should be empty, it is the first place to look because `nginx` is the first application handling the request your are sending to Huginn.
361
+
362
+Common problems:
363
+
364
+* `connect() to unix:/home/huginn/huginn/tmp/sockets/unicorn.socket failed`: The Unicorn application server is not running, ensure you uncommented one of the example configuration below the `PRODUCTION` label in your [Profile](#install-init-script) and the unicorn config file (`/home/huginn/huginn/config/unicorn.rb`) exists.
365
+* `138 open() "/home/huginn/huginn/public/..." failed (13: Permission denied)`: The `/home/huginn/huginn/public` directory needs to be readable by the nginx user (which is per default `www-data`)
366
+
367
+
368
+#### Unicorn log `/home/huginn/huginn/log/unicorn.log`
369
+
370
+Should only contain HTTP request log entries like: `10.0.2.2 - - [18/Aug/2015:21:15:12 +0000] "GET / HTTP/1.0" 200 - 0.0110`
371
+
372
+If you see ruby exception backtraces or other error messages the problem could be one of the following:
373
+
374
+* The configuration file `/home/huginn/huginn/config/unicorn.rb` does not exist
375
+* Gem dependencies where not [installed](#install-gems)
376
+
377
+#### Rails Application log `/home/huginn/huginn/log/production.log`
378
+
379
+This file is pretty verbose, you want to look at it if you are getting the `We're sorry, but something went wrong.` error message when using Huginn. This is an example backtrace that can help you or other huginn developers locate the issue:
380
+
381
+```
382
+NoMethodError (undefined method `name' for nil:NilClass):
383
+  app/controllers/jobs_controller.rb:6:in `index'
384
+  config/initializers/silence_worker_status_logger.rb:5:in `call_with_silence_worker_status'
385
+```
386
+
387
+#### Runit/Background Worker logs `/home/huginn/huginn/log/*/current`
388
+
389
+Those files will contain error messages or backtraces if one of your agent is not performing as they should. The easiest way to debug an Agent is to watch all your log files for changes and trigger the agent to run via the Huginn web interface.
390
+
391
+The log file location depends your `Procfile` configuration, this command will give you a list of the available logs:
392
+
393
+    ls -al /home/huginn/huginn/log/*/current
394
+
395
+When you want to monitor the background processes you can easily watch all the files for changes:
396
+
397
+    tail -f /home/huginn/huginn/log/*/current
398
+
399
+### Still having problems? :crying_cat_face:
400
+
401
+You probably found an error message or exception backtrace you could not resolve. Please create a new [issue](https://github.com/cantino/huginn/issues) and include as much information as you could gather about the problem your are experiencing.

+ 68 - 0
doc/manual/requirements.md

@@ -0,0 +1,68 @@
1
+# Requirements
2
+
3
+## Operating Systems
4
+
5
+### Supported Unix distributions by this guide
6
+
7
+- Ubuntu (14.04 and 12.04)
8
+- Debian (Jessie and Wheezy)
9
+
10
+### Unsupported Unix distributions
11
+
12
+- CentOS
13
+- Red Hat Enterprise Linux
14
+- OS X
15
+- Arch Linux
16
+- Fedora
17
+- Gentoo
18
+- FreeBSD
19
+
20
+On the above unsupported distributions is still possible to install Huginn, and many people do. Follow the [installation guide](./installation.md) and substitute the `apt` commands with the corresponding package manager commands of your distribution.
21
+
22
+### Non-Unix operating systems such as Windows
23
+
24
+Huginn is developed for Unix operating systems.
25
+Huginn does **not** run on Windows and we have no plans of supporting it in the near future.
26
+Please consider using a virtual machine to run Huginn on Windows.
27
+
28
+## Ruby versions
29
+
30
+Huginn requires Ruby (MRI) 2.0, 2.1 or 2.2
31
+You will have to use the standard MRI implementation of Ruby.
32
+We love [JRuby](http://jruby.org/) and [Rubinius](http://rubini.us/) but Huginn needs several Gems that have native extensions.
33
+
34
+## Hardware requirements
35
+
36
+### CPU
37
+
38
+- _single core_ setups will work but depending on the amount of Huginn Agents and users it will run a bit slower since the application server and background jobs can not run simultaneously
39
+- _dual core_ setups are the **recommended** system/vps and will work well for a decent amount of Agents
40
+- 3+ cores can be needed when running multiple DelayedJob workers
41
+
42
+### Memory
43
+
44
+You need at least 0.5GB of physical and 0.5GB of addressable memory (swap) to install and use Huginn with the default configuration!
45
+With less memory you need to manually adjust the `Gemfile` and Huginn can respond with internal server errors when accessing the web interface.
46
+
47
+- 256MB RAM + 0.5GB of swap is the absolute minimum but we strongly **advise against** this amount of memory. See the Wiki page about running Huginn on [systems with low memory](https://github.com/cantino/huginn/wiki/Running-Huginn-on-minimal-systems-with-low-RAM-&-CPU-e.g.-Raspberry-Pi)
48
+- 0.5GB RAM + 0.5GB swap will work relatively well with SSD drives, but can feel a bit slow due to swapping
49
+- 1GB RAM + 1GB swap will work with two unicorn workers and the threaded background worker
50
+- **2GB RAM** is the **recommended** memory size, it will support 2 unicorn workers and both the threaded and the old separate workers
51
+- for each 300MB of additional RAM you can run one extra DelayedJob worker
52
+
53
+## Unicorn Workers
54
+
55
+It's possible to increase the amount of unicorn workers and this will usually help for to reduce the response time of the applications and increase the ability to handle parallel requests.
56
+
57
+For most instances we recommend using: CPU cores = unicorn workers.
58
+
59
+If you have a 512MB machine we recommend to configure only one Unicorn worker and use the threaded background worker to prevent excessive swapping.
60
+
61
+
62
+## DelayedJob Workers
63
+
64
+A DelayedJob worker is a separate process which runs your Huginn Agents. It fetches Websites, polls external services for updates, etc. Depending on the amount of Agents and the check frequency of those you might need to run more than one worker (like it is done in the threaded setup).
65
+
66
+Estimating the amount of workers needed is easy. One worker can perform just one check at a time.  
67
+If you have 60 Agents checking websites every minute which take about 1 second to respond, one worker is fine.  
68
+If you need more Agents or are dealing with slow/unreliable websites/services, you should consider running additional workers.

+ 92 - 0
doc/manual/update.md

@@ -0,0 +1,92 @@
1
+# Update
2
+
3
+You can also use [Capistrano](./capistrano.md) to keep your installation up to date.
4
+
5
+### 0. Ensure depencies are up to date
6
+
7
+```
8
+cd /home/huginn/huginn
9
+sudo rake production:check
10
+```
11
+
12
+### 1. Stop server
13
+
14
+```
15
+sudo rake production:stop
16
+```
17
+
18
+### 2. Store the current version
19
+
20
+```
21
+export OLD_VERSION=`git rev-parse HEAD`
22
+```
23
+
24
+### 3. Update the code
25
+
26
+Back up changed files
27
+
28
+```
29
+sudo -u huginn -H cp Procfile Procfile.bak
30
+```
31
+
32
+Get the new code
33
+```
34
+sudo -u huginn -H git fetch --all
35
+sudo -u huginn -H git checkout -- db/schema.rb Procfile
36
+sudo -u huginn -H git checkout master
37
+sudo -u huginn -H git pull
38
+```
39
+
40
+Restore backed up files
41
+
42
+```
43
+sudo -u huginn -H cp Procfile.bak Procfile
44
+```
45
+
46
+### 4. Install gems, migrate and precompile assets
47
+
48
+```
49
+cd /home/huginn/huginn
50
+
51
+sudo -u huginn -H bundle install --deployment --without development test
52
+
53
+# Run database migrations
54
+sudo -u huginn -H bundle exec rake db:migrate RAILS_ENV=production
55
+
56
+# Clean up assets and cache
57
+sudo -u huginn -H bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production
58
+
59
+```
60
+
61
+### 5. Update the Procfile
62
+
63
+Check for changes made to the default `Procfile`
64
+```
65
+sudo -u huginn -H git diff $OLD_VERSION..master Procfile
66
+```
67
+
68
+Update your `Procfile` if the default options of the version you are using changed
69
+```
70
+sudo -u huginn -H editor Procfile
71
+```
72
+
73
+### 6. Update the .env file
74
+
75
+Check for changes made to the example `.env`
76
+```
77
+sudo -u huginn -H git diff $OLD_VERSION..master .env.example
78
+```
79
+
80
+Update your `.env` with new options or changed defaults
81
+```
82
+sudo -u huginn -H editor .env
83
+```
84
+
85
+
86
+### 7. Export init script and start Huginn
87
+
88
+```
89
+# Export the init script
90
+sudo rake production:export
91
+```
92
+

+ 94 - 0
lib/tasks/production.rake

@@ -0,0 +1,94 @@
1
+def failed; "[ \033[31mFAIL\033[0m ]"; end
2
+def ok;     "[  \033[32mOK\033[0m  ]"; end
3
+
4
+def run_as_root
5
+  return true if ENV['USER'] == 'root'
6
+  puts "#{failed} Please run this command as root or with sudo\n\n"
7
+  exit -1
8
+end
9
+
10
+def runit_installed
11
+  return true unless `which sv` && $?.to_i != 0
12
+  puts "#{failed} Please install runit: \n\nsudo apt-get install runit\n\n"
13
+  exit -1
14
+end
15
+
16
+def remove_upstart_config
17
+  return true unless File.exists?('/etc/init/huginn.conf')
18
+  puts "#{failed} Please stop huginn and remove the huginn upstart init scripts:\n\n"
19
+  puts "sudo stop huginn"
20
+  puts "sudo rm /etc/init/huginn*\n\n"
21
+  exit -1
22
+end
23
+
24
+namespace :production do
25
+  task :check do |t|
26
+    remove_upstart_config
27
+    runit_installed
28
+    puts "#{ok} Everything is fine" if t.application.top_level_tasks.include? 'production:check'
29
+  end
30
+
31
+  task :stop => :check do
32
+    puts "Stopping huginn ..."
33
+    run_sv('stop')
34
+  end
35
+
36
+  task :start => :check do
37
+    puts "Startig huginn ..."
38
+    run_sv('start')
39
+  end
40
+
41
+  task :status => :check do
42
+    run_sv('status')
43
+  end
44
+
45
+  task :restart => :check do
46
+    puts "Restarting huginn ..."
47
+    run_sv('restart')
48
+  end
49
+
50
+  task :export => :check do
51
+    run_as_root
52
+    Rake::Task['production:stop'].execute
53
+    puts "Exporting new services ..."
54
+    run('rm -rf /etc/service/huginn*')
55
+    run('foreman export runit -a huginn -l /home/huginn/huginn/log /etc/service')
56
+    services = Dir.glob('/etc/service/huginn*')
57
+    while services.length > 0
58
+      services.each do |p|
59
+        supervise = File.join(p, 'supervise')
60
+        next if !Dir.exists?(supervise)
61
+        run("chown -R huginn:huginn #{p}")
62
+        services.delete(p)
63
+      end
64
+      sleep 0.1
65
+    end
66
+  end
67
+end
68
+
69
+def run_sv(command)
70
+  Dir.glob('/etc/service/huginn*').each do |p|
71
+    with_retries do
72
+      run("sv #{command} #{File.basename(p)}")
73
+    end
74
+  end
75
+end
76
+
77
+def run(cmd, verbose=false)
78
+  output = `#{cmd}`
79
+  if $?.to_i != 0
80
+    raise "'#{cmd}' exited with a non-zero return value: #{output}"
81
+  end
82
+  puts output if verbose && output.strip != ''
83
+  output
84
+end
85
+
86
+def with_retries(&block)
87
+  tries ||= 5
88
+  output = block.call
89
+rescue StandardError => e
90
+  retry unless (tries -= 1).zero?
91
+  raise e
92
+else
93
+  puts output
94
+end