-
Notifications
You must be signed in to change notification settings - Fork 0
Deployment with Capistrano, Unicorn, nginx, Foreman, and Upstart
Deploying Huginn with Capistrano, Unicorn, and nginx is straight forward. You can read more about using Foreman and Upstart together in general here.
Follow these steps:
-
Edit your Gemfile and add the following:
group :production do gem 'unicorn' end group :development do gem 'capistrano' gem 'rvm-capistrano' end
-
Run
bundle
again after you do this to installcapistrano
andrvm-capistrano
. -
Setup a place for Huginn to run. I recommend making a dedicated user on your server for Huginn, but this is not required. Setup nginx or Apache to proxy pass to unicorn. There is an example nginx script in
doc/deployment/nginx/production.conf
. -
Setup a production database on your server for Huginn.
-
Copy
doc/deployment/unicorn/production.rb
toconfig/unicorn/production.rb
and replace instances of you with the correct username for your server. -
Copy
doc/deployment/capistrano/deploy.rb
toconfig/deploy.rb
and change all instances ofyou
andyourdomain
to the appropriate values for your server setup. If you want RVM to be used and installed, uncomment the appropriate lines. If you use RVM in multi-user mode, changeset rvm_type :user
toset rvm_type :system
. -
Run
cap deploy:setup
to create the basic Capistrano directory structure on your server. -
Make a copy of your
.env
file, setup your production settings, create a directory called/home/you/app/shared/config
on your server, and place your production.env
file in this directory.- To generate
APP_SECRET_TOKEN
, you can runbundle exec rake secret
in your Huginn directory. - Change
DOMAIN
to match what your web server is listening for, e.g.http://yourdomain.com
. - Set up the database with the credentials you used to create the production database earlier.
- Follow the instructions in the comments to set up mail sending.
- Note that G{oogle M,m}ail will usually only accept sender emails that are already set up in your Accounts options.
- Change
RAILS_ENV
toproduction
. - If you don't want people to join your Huginn instance, make the
INVITATION_CODE
something long and unguessable. Commenting it out will still default totry-huginn
. - The rest can be left as it is.
- To generate
-
Make a copy of your
Procfile
, set it up for production, and place the copy in/home/you/app/shared/config
on your server, just like you did with the.env
file for production. Comment out the default development settings and comment in the default production settings. -
Run
cap deploy
. SSH into your server, go to yourdeploy_to
directory, and checkout the logs coming from foreman and upstart inupstart_logs
andapp/current/logs
. You may wish to setup logrotate, especially for the Twitter agent log. -
Run
RAILS_ENV=production bundle exec rake db:seed
to generate your admin user. Immediately login to your new Huginn installation with the username ofadmin
and the password ofpassword
and change your email and password!
If you have improvements to this setup, please share!