http://jay.gooby.org/tag/unicorn Posts tagged with "unicorn" - Jay Caines-Gooby 2010-08-02T18:10:56+01:00 Jay Caines-Gooby jay@gooby.org http://jay.gooby.org/ http://jay.gooby.org/post/an-etcinitdunicorn-script-for-multiple-unicorn-installations An /etc/init.d/unicorn script for multiple unicorn installations 2010-08-02T18:10:56+01:00 2010-08-06T00:29:39+01:00 <p>Our staging server needed to be able to run multiple <a href="http://unicorn.bogomips.org/">unicorns</a>, each responsible for a different rails app, e.g. QA and staging</p> <p>I wanted a simple /etc/init.d script that will start/stop/reload all my unicorns or just a specific one:</p> <pre name="code" class='bash:nogutter'> # 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 </pre> <p>The /etc/unicorn files are just simple variable setters. Here&#8217;s a sample /etc/unicorn/staging.conf</p> <pre name="code" class='shell'> RAILS_ROOT=/var/www/apps/e_learning_staging/current RAILS_ENV=development </pre> <p>Here&#8217;s the script to <a href="http://gist.github.com/504875">save as /etc/init.d/unicorn</a> (in case the gist doesn&#8217;t embed below) &#8211; don&#8217;t forget to run <code>sudo /usr/sbin/update-rc.d -f unicorn defaults</code> to link it up to your <a href="http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian">rc.d scripts</a> for running at boot time.</p> <script src="http://gist.github.com/504875.js"></script><p>Enjoy!</p>