unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Josh Sharpe <josh.m.sharpe@gmail.com>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: unicorn upstart script
Date: Sun, 11 Aug 2013 15:38:09 -0400	[thread overview]
Message-ID: <CAM2RUGMytrV+8s-K5sm7YnsjrcbTJkmGzGCU5mQTdVVeKr9Hpg@mail.gmail.com> (raw)
In-Reply-To: <CAAB-KcnV+5DFd_3vZC2+Q_e5jw7SjFgQaet552JxrD-TFS3C-w@mail.gmail.com>

I like the unicorn_forever idea, but as it's lightly tested, I
continued down the path of trying to hack upstart into compliance and
came up with this...  Might as well share.

This works nicely when USR2 is received, and restarts the master if
for whatever reason it dies.

Cheers!

$ cat /etc/init/unicorn.conf
description "Unicorn configuration"

start on filesystem
stop on shutdown

respawn

kill signal QUIT

script
  start-stop-daemon --start --chuid blue --chdir
/u/apps/blue-test-app/current --exec /usr/bin/bundle exec
unicorn_rails -- -c /u/apps/blue-test-app/shared/system/unicorn.cfg -E
production

  exists=0
  pidfile=/tmp/unicorn.master.pid
  oldpidfile=/tmp/unicorn.master.pid.oldbin

  while [ $exists -eq 0 ]
  do
    sleep 0.1

    (test -f $pidfile && pgrep -P $(cat $pidfile)) || (test -f
$oldpidfile && pgrep -P $(cat $oldpidfile))
    exists=$?
  done

  exec rm /tmp/unicorn.master.pid
  exec rm /tmp/unicorn.master.pid.oldbin

  exit 1
end script

On Sat, Aug 10, 2013 at 2:20 AM, Hleb Valoshka <375gnu@gmail.com> wrote:
> On 8/10/13, Josh Sharpe <josh.m.sharpe@gmail.com> wrote:
>> I'm thinking a a wrapper script maybe required that stays running even
>> in the event of USR2 to being sent to unicorn, and only dies if the
>> process identified in the PID file is missing.
>
> https://rubyforge.org/pipermail/mongrel-unicorn/2013-July/001820.html
> _______________________________________________
> Unicorn mailing list - mongrel-unicorn@rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-unicorn
> Do not quote signatures (like this one) or top post when replying
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

  reply	other threads:[~2013-08-11 20:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 22:02 unicorn upstart script Josh Sharpe
2013-08-10  6:20 ` Hleb Valoshka
2013-08-11 19:38   ` Josh Sharpe [this message]
2013-08-10  6:21 ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM2RUGMytrV+8s-K5sm7YnsjrcbTJkmGzGCU5mQTdVVeKr9Hpg@mail.gmail.com \
    --to=josh.m.sharpe@gmail.com \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).