unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Ben Somers <somers.ben@gmail.com>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Detecting unicorn / defining after_fork after master startup
Date: Thu, 19 Jul 2012 15:55:54 -0700	[thread overview]
Message-ID: <CAO1NZApAHvQVy9WzToZ60svR1KygnaAAEfuB+hi=feGqwNVbuQ@mail.gmail.com> (raw)
In-Reply-To: <CAJf_-Utd8NE4rL68mj-8=4q+O+9NrMF8j7e213N13Xcw718A=Q@mail.gmail.com>

> 1. What is the best way to determine whether the app is indeed running
> inside a unicorn server?

I actually wound up just setting an environment variable for this. I
manage unicorn through an init.d, and just export UNICORN=true before
it starts up the server. We have the exact scenario you describe,
Unicorn in production and Passenger on our dev machines.

> 2. Is there an established way for adding an after_fork hook after
> Unicorn has already started up?

I just recently had to solve this problem for my team. In my case,
I've got multiple applications getting their unicorn configs managed
through chef, and so didn't want to fill the chef with app-specific
switches. Since the unicorn config file is just ruby code, I just have
my config files check the app directory for a unicorn directory
containing before_fork.rb and after_fork.rb files and load the files
if they exist. It doesn't register the hooks after Unicorn starts, but
it does let you define them outside of the config file.
_______________________________________________
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:[~2012-07-19 22:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 22:43 Detecting unicorn / defining after_fork after master startup Matt Sanders
2012-07-19 22:55 ` Ben Somers [this message]
2012-07-19 22:59   ` Matt Sanders
2012-07-19 23:13 ` Eric Wong
2012-07-21 19:42   ` Matt Sanders
2012-07-22 21:20     ` 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='CAO1NZApAHvQVy9WzToZ60svR1KygnaAAEfuB+hi=feGqwNVbuQ@mail.gmail.com' \
    --to=somers.ben@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).