* global variable in after_fork
@ 2015-01-23 18:32 Joe Williams
2015-01-24 23:30 ` Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Joe Williams @ 2015-01-23 18:32 UTC (permalink / raw)
To: unicorn-public
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?
Thanks!
-Joe
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: global variable in after_fork
2015-01-23 18:32 global variable in after_fork Joe Williams
@ 2015-01-24 23:30 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-01-24 23:30 UTC (permalink / raw)
To: Joe Williams; +Cc: unicorn-public
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-24 23:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23 18:32 global variable in after_fork Joe Williams
2015-01-24 23:30 ` Eric Wong
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).