Our staging server needed to be able to run multiple unicorns, each responsible for a different rails app, e.g. QA and staging
I wanted a simple /etc/init.d script that will start/stop/reload all my unicorns or just a specific one:
# starts all unicorns listed in /etc/unicorn/*.conf /etc/init.d/unicorn start # stops the QA unicorn /etc/init.d/unicorn stop /etc/unicorn/qa.conf
The /etc/unicorn files are just simple variable setters. Here’s a sample /etc/unicorn/staging.conf
RAILS_ROOT=/var/www/apps/e_learning_staging/current RAILS_ENV=development
Here’s the script to save as /etc/init.d/unicorn (in case the gist doesn’t embed below) – don’t forget to run sudo /usr/sbin/update-rc.d -f unicorn defaults to link it up to your rc.d scripts for running at boot time.
Enjoy!
Comments
Script is not working right
Hi,
The script works fine for a single site, but when I have more than one conf file, it exits after the first site has been started/stopped.
I think the issue is that exit 0 statements.
Otherwise nice.
Thomas