Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Chef Cookbook to create init.d-scripts for unicorn webapps
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
providers
recipes
resources
templates/default
LICENSE
README.md
metadata.rb

README.md

unicorn_init

Description

This chef cookbook provides a Lightweight Resources and Providers (LWRP) for dealing with unicorn apps and initd. For example when you have a bunch of deployed ruby apps with unicorn and your deploment is capistrano based. This LWRP allows you to easily create init.d services which get started on (re)boot, too.

This is pretty much customized of our current deployment schema but can be configured:

e.g.

  • given an rails application named "piraten6"
  • given the user running the app is "webapp1"
  • given the capistrano current/releases-dir schema is used

Example 1:

unicorn_init 'piraten6' do
  user 'webapp1'
  apps_root '/home/webapp1/apps'

  # assumes app is deployed to /home/webapp1/apps/piraten6/current
  # assumes unicorn config in  /home/webapp1/apps/piraten6/current/config/unicorn/production.rb
  # uses sudo -u webapp1 -i (e.g. for rbenv, rvm)
  # assumes bundler-binstub for unicorn in /home/webapp1/apps/piraten6/current/bin/unicorn
  #   => capistrano for rbenv:
  #      set :bundle_flags,    '--deployment --quiet --binstubs --shebang ruby-local-exec'
  #
end

=> Will create an /etc/init.d/webapp_piraten6 service and "service :enable" it (update-rc.d-insserv).

Example 2:

unicorn_init 'piraten6' do
  user 'webapp1' # example
  apps_root '/home/webapp1/apps'  # example
  environment 'production'  # default
  unicorn_name 'unicorn'    # default, change for e.g. unicorn_rails

  init_name 'webapp_piraten6' # calculated unless set, results in /etc/init.d/webapp_piraten6
  app_dir '/home/webapps/apps/piraten6'  # calculated unless set
  current_app_dir  '/home/webapps/apps/piraten6/current' # calculated unless set
  unicorn_path '/home/webapps/apps/piraten6/current/config/unicorn/production.rb' # calculated unless set

end

see resources/default.rb and provides/default.rb for more information/settings.

Template is templates/default/unicorn_init.erb. Based on the Ubuntu 12.04 /etc/init.d/skeleton template

Copyright

Copyright (C) 2012 Moriz GmbH

Copyright (C) 2012 Roland Moriz

Licenses under the Apache 2.0 license, see bundled file LICENSE for the full text. Exception: Template unicorn_init.erb is licensed under the terms of Ubuntu 12.04 for /etc/init.d/skeleton probably GNU General Public License v2 or later.

Something went wrong with that request. Please try again.