unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: Joe Williams <williams.joe@gmail.com>
Cc: unicorn-public@bogomips.org
Subject: Re: global variable in after_fork
Date: Sat, 24 Jan 2015 23:30:59 +0000	[thread overview]
Message-ID: <20150124233059.GA5453@dcvr.yhbt.net> (raw)
In-Reply-To: <CAJtkKzZ35_7tMFx5dNQbHASGEjYiE5pL7EWHDnhLQ4P8zPCJ7Q@mail.gmail.com>

Joe Williams <williams.joe@gmail.com> wrote:
> I am attempting to do something like the following:
> after_fork do |server, worker|
>   $unicorn_uptime = Time.now.to_i.to_s
>   $unicorn_uptime.freeze
> <snip>
> Unfortunately the variable comes up nil when later accessed. Anyone have
> thoughts on what I am missing?

I tried your after_fork hook with the following config.ru
and it prints out $unicorn_uptime fine:

-------------------- config.ru --------------------------
use Rack::ContentLength
use Rack::ContentType, 'text/plain'
run lambda { |env| [ 200, {}, [ "#$unicorn_uptime\n"] ] }

Perhaps you have something else in your app clobbering globals?

Also, please don't send any HTML parts in mail, it is spammy and wastes
bandwidth/storage.  Your message would've been seen much sooner if it
hadn't been flagged as spam.  Thanks.

      reply	other threads:[~2015-01-24 23:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 18:32 global variable in after_fork Joe Williams
2015-01-24 23:30 ` Eric Wong [this message]

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:

  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=20150124233059.GA5453@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=unicorn-public@bogomips.org \
    --cc=williams.joe@gmail.com \


* 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


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).