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
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.