unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: mongrel-unicorn@rubyforge.org
Subject: Re: "unicorn -D" always returns 0 "success" (even when failed to load)
Date: Wed, 23 Dec 2009 11:22:27 +0100	[thread overview]
Message-ID: <200912231122.28331.ibc@aliax.net> (raw)
In-Reply-To: <20091223072617.GA28704@dcvr.yhbt.net>

El Miércoles, 23 de Diciembre de 2009, Eric Wong escribió:

> No way to determine that currently, as I've never encountered the need.
> 
> For validating startups, most folks I know have specific endpoint(s) in
> application dedicated to checks.  That way they can get way more info
> and all the way down into stack including things like database/memcached
> connections.

Yes, you are right and I agree now. I was thinking in Unicorn as a final 
application rather than a HTTP applications container. It's like Apache, no 
body expects Apache to return 1 and exit in case a PHP application has a typo 
:)



> > Usually if a worker (all the workers) fail to start at the moment of
> > running it, it obviously means that there is some error in the
> > application with prevents it to run. It could be great if Unicorn could
> > detect it.
> 
> I'm generally hesitant to introduce code/features/bloat that aren't
> helpful to people who properly test configurations before deploying :)
> 
> Adding this code doesn't solve problems.  Either way the site can become
> inaccessible/unusable and problems are noticeable very quickly.

Sure, but how to explain that to Hearteat? :)

 
> If there's sufficient interest, I'll consider accepting a small patch
> for this.  Right now I'm unconvinced...

I've taken a look to the code and such a feature would definitively make it 
ugly (IMHO).

So I'm thinking in a different approach: a custom script to check the status 
of the application. Such script would communicate with the application (maybe 
using DRB). If the DRB connection fails (because the workers fail to start) 
then it means that something wrong occurs. And such script would also return 
the whole status (DB connections and so).
I would include such script as "status" option in a service init script. The 
"start" action would call "status" after N seconds and decide if the 
*application* is running or not (if not then kill unicorn and exit 1).

PS: Since Unicorn makes usage of signals, is there any way to determine (by 
using a signal) if the process running with some PID is an unicorn process?

This is: usually to verify the process status the PID file/value is inspected. 
If there is a process running under such PID then we "assume" that process is 
Unicorn. In case that PID is stolen by any other process (since PID file 
wasn't deleted) nobody realizes of it.

A way to determine it could be asking to Unicorn master process (using i.e. 
DRB) its PID and match it against the PID value stored in the pidfile. Of 
course it would require some kind of communication with unicorn master process 
to get its PID, is it possible now in some way?



 
> > For that I suggest something as a new option "--validation-time TIME".
> > Let's suppose TIME is 5 seconds. In case *all* the workers fail within 5
> > seconds after starting unicorn, then unicorn understands that the Rack
> > application is wrong (or any other error as Errno::EADDRINUSE) so
> > terminates all the workers and itself (and hopefully returns 1 or any
> > other non-zero exit status).
> >
> > Of course, all the above means that Unicorn should wait TIME seconds
> > before being daemonized (so after TIME seconds it can decide which code
> > to return).
> >
> > Does it make sense? Thanks a lot.
> 
> We avoid introducing command-line options since they're unlikely to be
> compatible with "rackup" parsing of the "#\" lines in .ru files.

I didn't know about such options in .ru file. Are those options supposed to be 
read by the backend?


Thanks a lot.

-- 
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
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:[~2009-12-23 10:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23  2:20 "unicorn -D" always returns 0 "success" (even when failed to load) Iñaki Baz Castillo
2009-12-23  7:26 ` Eric Wong
2009-12-23 10:22   ` Iñaki Baz Castillo [this message]
2009-12-23 20:35     ` Eric Wong
2009-12-24  9:30       ` Iñaki Baz Castillo
2009-12-24 19:34         ` Eric Wong
2009-12-25 22:09           ` Iñaki Baz Castillo
2009-12-26  1:30             ` Iñaki Baz Castillo
2009-12-25 23:58   ` Iñaki Baz Castillo
  -- strict thread matches above, loose matches on Subject: below --
2009-12-26  4:29 Iñaki Baz Castillo
2009-12-26  6:16 ` Eric Wong
2009-12-26 15:47   ` Iñaki Baz Castillo
2009-12-26 18:23     ` Iñaki Baz Castillo
2009-12-27  1:31       ` Eric Wong
2009-12-27  3:06         ` Iñaki Baz Castillo
2009-12-27  3:07           ` Iñaki Baz Castillo
2009-12-28  3:29           ` Eric Wong
2009-12-28 10:39             ` Iñaki Baz Castillo
2009-12-28 12:50             ` Iñaki Baz Castillo
2009-12-28 19:25               ` Eric Wong
2009-12-28 20:17                 ` Iñaki Baz Castillo
2009-12-28 20:32                   ` Eric Wong
2009-12-28 20:41                     ` Iñaki Baz Castillo
2009-12-29  0:17                       ` Eric Wong
2009-12-29  0:32                         ` Iñaki Baz Castillo

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=200912231122.28331.ibc@aliax.net \
    --to=ibc@aliax.net \
    --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).