Jay Caines-Gooby

Back in 5 mins

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.



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.


Gravatar icon
Thursday August 26, 2010 @ 08:42 AM (BST)
New comment

required, won't be displayed


Don't type anything here unless you're an evil robot:

And especially don't type anything here:

Basic XHTML (including links) is allowed, just don't try anything fishy. Your comment will be auto-formatted unless you use your own <p> tags for formatting. You're also welcome to use Textile.

Copyright © 2011 Jay Caines-Gooby. All rights reserved.
Powered by Thoth.