librelist archives

« back to archive

experiments with before_pause failing hard

experiments with before_pause failing hard

From:
Josh Sharpe
Date:
2013-06-11 @ 14:54
I've been trying to get Resque#before_pause to work and it's not
playing nice.  I have a rails initializer that looks something like
this:

config/initializers/resque.rb:

Resque.before_pause do |worker|
  File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
    f << $$
  end
  File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
    f << ENV['PIDFILE']
  end
  File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
    f << 'hello'
  end
  exit 1
end

Resque.after_fork do |worker|
  # raise 'dammit'
  defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection

  Resque.redis = Redis.new(RedisConnection.configuration)
end


A couple of things about this initializer.

1) The #after_fork hook is definitely working.  Uncommenting that
first line raises obvious hell.  Under normal circumstances I see
stuff like this in the logs:

*** Running before_fork hooks with....
*** resque-1.24.1: Forked 14511 at 1370961746
*** Running after_fork hooks

.... and ActiveRecord::Base doesn't throw connection errors and such.

2)  The before_pause *should* be raising hell (exit 1).  And even if
there was some permission issue on writing those files it should be
blowing up, but there's nothing:

Logs look something like this:

*** resque-1.24.1: Processing high since 1370961746 [FooJob]
*** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
*** resque-1.24.1: Forked 14511 at 1370961746
*** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
*** USR2 received; pausing job processing
*** done: (Job{high} | FooJob | ["prk", {}])
*** Sleeping for 5.0 seconds
*** resque-1.24.1: Paused
*** Sleeping for 5.0 seconds
*** resque-1.24.1: Paused
*** Sleeping for 5.0 seconds
*** resque-1.24.1: Paused

So there's the USR2, and the pausing works (there are more jobs on the
queue not getting consume)... But before_hook wasn't executed.

Thanks!
Josh

Re: experiments with before_pause failing hard

From:
Josh Sharpe
Date:
2013-06-11 @ 15:12
I'm gonna go ahead and answer this one:

Because that method is on master, and not on 1.24.1.

On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <josh.m.sharpe@gmail.com> wrote:
> I've been trying to get Resque#before_pause to work and it's not
> playing nice.  I have a rails initializer that looks something like
> this:
>
> config/initializers/resque.rb:
>
> Resque.before_pause do |worker|
>   File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
>     f << $$
>   end
>   File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
>     f << ENV['PIDFILE']
>   end
>   File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
>     f << 'hello'
>   end
>   exit 1
> end
>
> Resque.after_fork do |worker|
>   # raise 'dammit'
>   defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
>
>   Resque.redis = Redis.new(RedisConnection.configuration)
> end
>
>
> A couple of things about this initializer.
>
> 1) The #after_fork hook is definitely working.  Uncommenting that
> first line raises obvious hell.  Under normal circumstances I see
> stuff like this in the logs:
>
> *** Running before_fork hooks with....
> *** resque-1.24.1: Forked 14511 at 1370961746
> *** Running after_fork hooks
>
> .... and ActiveRecord::Base doesn't throw connection errors and such.
>
> 2)  The before_pause *should* be raising hell (exit 1).  And even if
> there was some permission issue on writing those files it should be
> blowing up, but there's nothing:
>
> Logs look something like this:
>
> *** resque-1.24.1: Processing high since 1370961746 [FooJob]
> *** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> *** resque-1.24.1: Forked 14511 at 1370961746
> *** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> *** USR2 received; pausing job processing
> *** done: (Job{high} | FooJob | ["prk", {}])
> *** Sleeping for 5.0 seconds
> *** resque-1.24.1: Paused
> *** Sleeping for 5.0 seconds
> *** resque-1.24.1: Paused
> *** Sleeping for 5.0 seconds
> *** resque-1.24.1: Paused
>
> So there's the USR2, and the pausing works (there are more jobs on the
> queue not getting consume)... But before_hook wasn't executed.
>
> Thanks!
> Josh

Re: [resque] Re: experiments with before_pause failing hard

From:
Emil Kampp
Date:
2013-06-11 @ 15:14
Hehe.. I love those instances, where one figures something out just after 
posting it :) 


Best regards / Venlig hilsen

Emil Kampp
Kampp Media
Baltorpvej 189, st.-1, DK 2750
emil.kampp.me | emil@kampp.me | +45 42427176 | CVR: DK30160983


On Tuesday, June 11, 2013 at 5:12 PM, Josh Sharpe wrote:

> I'm gonna go ahead and answer this one:
> 
> Because that method is on master, and not on 1.24.1.
> 
> On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <josh.m.sharpe@gmail.com 
(mailto:josh.m.sharpe@gmail.com)> wrote:
> > I've been trying to get Resque#before_pause to work and it's not
> > playing nice. I have a rails initializer that looks something like
> > this:
> > 
> > config/initializers/resque.rb:
> > 
> > Resque.before_pause do |worker|
> > File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
> > f << $$
> > end
> > File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
> > f << ENV['PIDFILE']
> > end
> > File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
> > f << 'hello'
> > end
> > exit 1
> > end
> > 
> > Resque.after_fork do |worker|
> > # raise 'dammit'
> > defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
> > 
> > Resque.redis = Redis.new(RedisConnection.configuration)
> > end
> > 
> > 
> > A couple of things about this initializer.
> > 
> > 1) The #after_fork hook is definitely working. Uncommenting that
> > first line raises obvious hell. Under normal circumstances I see
> > stuff like this in the logs:
> > 
> > *** Running before_fork hooks with....
> > *** resque-1.24.1: Forked 14511 at 1370961746
> > *** Running after_fork hooks
> > 
> > .... and ActiveRecord::Base doesn't throw connection errors and such.
> > 
> > 2) The before_pause *should* be raising hell (exit 1). And even if
> > there was some permission issue on writing those files it should be
> > blowing up, but there's nothing:
> > 
> > Logs look something like this:
> > 
> > *** resque-1.24.1: Processing high since 1370961746 [FooJob]
> > *** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> > *** resque-1.24.1: Forked 14511 at 1370961746
> > *** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> > *** USR2 received; pausing job processing
> > *** done: (Job{high} | FooJob | ["prk", {}])
> > *** Sleeping for 5.0 seconds
> > *** resque-1.24.1: Paused
> > *** Sleeping for 5.0 seconds
> > *** resque-1.24.1: Paused
> > *** Sleeping for 5.0 seconds
> > *** resque-1.24.1: Paused
> > 
> > So there's the USR2, and the pausing works (there are more jobs on the
> > queue not getting consume)... But before_hook wasn't executed.
> > 
> > Thanks!
> > Josh
> > 
> 
> 
> 

Re: [resque] Re: experiments with before_pause failing hard

From:
Eoin Coffey
Date:
2013-06-11 @ 15:17
Although as the author of that feature I thought I had backported it to
1-x-stable :-)


On Tue, Jun 11, 2013 at 9:14 AM, Emil Kampp <emil@kampp.me> wrote:

>
> Hehe.. I love those instances, where one figures something out just after
> posting it :)
>
>
> Best regards / Venlig hilsen
>
> Emil Kampp
> Kampp Media
> Baltorpvej 189, st.-1, DK 2750
> emil.kampp.me | emil@kampp.me | +45 42427176 | CVR: DK30160983
>
> On Tuesday, June 11, 2013 at 5:12 PM, Josh Sharpe wrote:
>
> I'm gonna go ahead and answer this one:
>
> Because that method is on master, and not on 1.24.1.
>
> On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <josh.m.sharpe@gmail.com>
> wrote:
>
> I've been trying to get Resque#before_pause to work and it's not
> playing nice. I have a rails initializer that looks something like
> this:
>
> config/initializers/resque.rb:
>
> Resque.before_pause do |worker|
> File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
> f << $$
> end
> File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
> f << ENV['PIDFILE']
> end
> File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
> f << 'hello'
> e nd
> exit 1
> end
>
> Resque.after_fork do |worker|
> # raise 'dammit'
> defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
>
> Resque.redis = Redis.new(RedisConnection.configuration)
> end
>
>
> A couple of things about this initializer.
>
> 1) The #after_fork hook is definitely working. Uncommenting that
> first line raises obvious hell. Under normal circumstances I see
> stuff like this in the logs:
>
> *** Running before_fork hooks with....
> *** resque-1.24.1: Forked 14511 at 1370961746
> *** Running after_fork hooks
>
> .... and ActiveRecord::Base doesn't throw connection errors and such.
>
> 2) The before_pause *should* be raising hell (exit 1). And even if
> there was some permission issue on writing those files it should be
> blowing up, but there's nothing:
>
> Logs look something like this:
>
> *** resque-1.24.1: Processing high since 1370961746 [FooJob]
> *** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> *** resque-1.24.1: Forked 14511 at 1370961746
> *** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> *** USR2 received; pausing job processing
> *** done: (Job{high} | FooJob | ["prk", {}])
> *** Sleeping for 5.0 seconds
> *** resque-1.24.1: Paused
> *** Sleeping for 5.0 seconds
> *** resque-1.24.1: Paused
> *** Sleeping for 5.0 seconds
> *** resque-1.24.1: Paused
>
> So there's the USR2, and the pausing works (there are more jobs on the
> queue not getting consume)... But before_hook wasn't executed.
>
> Thanks!
> Josh
>
>
>

Re: [resque] Re: experiments with before_pause failing hard

From:
Josh Sharpe
Date:
2013-06-11 @ 15:35
You know... I think the setting of the hook, and some tests got
backported, but the changes to worker.rb did not (or got blown away)

~/resque (v1.24.1) $ grep -R after_pause lib/ test/
lib/resque.rb:  # Set the after_pause proc.
lib/resque.rb:  # The `after_pause` hook will be run in the parent
process after the
lib/resque.rb:  def after_pause(&block)
lib/resque.rb:    block ? register_hook(:after_pause, block) :
hooks(:after_pause)
lib/resque.rb:  attr_writer :after_pause

...nothing in worker.rb....  Wut?

Anyways, I can't get the test suite running - could someone check that?

Also, I just did this and am going to run off my fork for right now:


https://github.com/crankharder/resque/commit/cb6de84520b6b5acf21b2d1534c5666cde483975

...which works.  All my files showed up after USR2. Holla.

Josh



On Tue, Jun 11, 2013 at 11:17 AM, Eoin Coffey <ecoffey@gmail.com> wrote:
> Although as the author of that feature I thought I had backported it to
> 1-x-stable :-)
>
>
> On Tue, Jun 11, 2013 at 9:14 AM, Emil Kampp <emil@kampp.me> wrote:
>>
>>
>> Hehe.. I love those instances, where one figures something out just after
>> posting it :)
>>
>>
>> Best regards / Venlig hilsen
>>
>> Emil Kampp
>> Kampp Media
>> Baltorpvej 189, st.-1, DK 2750
>> emil.kampp.me | emil@kampp.me | +45 42427176 | CVR: DK30160983
>>
>> On Tuesday, June 11, 2013 at 5:12 PM, Josh Sharpe wrote:
>>
>> I'm gonna go ahead and answer this one:
>>
>> Because that method is on master, and not on 1.24.1.
>>
>> On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <josh.m.sharpe@gmail.com>
>> wrote:
>>
>> I've been trying to get Resque#before_pause to work and it's not
>> playing nice. I have a rails initializer that looks something like
>> this:
>>
>> config/initializers/resque.rb:
>>
>> Resque.before_pause do |worker|
>> File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
>> f << $$
>> end
>> File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
>> f << ENV['PIDFILE']
>> end
>> File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
>> f << 'hello'
>> e nd
>> exit 1
>> end
>>
>> Resque.after_fork do |worker|
>> # raise 'dammit'
>> defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
>>
>> Resque.redis = Redis.new(RedisConnection.configuration)
>> end
>>
>>
>> A couple of things about this initializer.
>>
>> 1) The #after_fork hook is definitely working. Uncommenting that
>> first line raises obvious hell. Under normal circumstances I see
>> stuff like this in the logs:
>>
>> *** Running before_fork hooks with....
>> *** resque-1.24.1: Forked 14511 at 1370961746
>> *** Running after_fork hooks
>>
>> .... and ActiveRecord::Base doesn't throw connection errors and such.
>>
>> 2) The before_pause *should* be raising hell (exit 1). And even if
>> there was some permission issue on writing those files it should be
>> blowing up, but there's nothing:
>>
>> Logs look something like this:
>>
>> *** resque-1.24.1: Processing high since 1370961746 [FooJob]
>> *** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
>> *** resque-1.24.1: Forked 14511 at 1370961746
>> *** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
>> *** USR2 received; pausing job processing
>> *** done: (Job{high} | FooJob | ["prk", {}])
>> *** Sleeping for 5.0 seconds
>> *** resque-1.24.1: Paused
>> *** Sleeping for 5.0 seconds
>> *** resque-1.24.1: Paused
>> *** Sleeping for 5.0 seconds
>> *** resque-1.24.1: Paused
>>
>> So there's the USR2, and the pausing works (there are more jobs on the
>> queue not getting consume)... But before_hook wasn't executed.
>>
>> Thanks!
>> Josh
>>
>>
>

Re: [resque] Re: experiments with before_pause failing hard

From:
Eoin Coffey
Date:
2013-06-11 @ 15:39
Yeah something got dropped in worker.rb for sure, nice catch.

If you can beat me to the PR, I'll happily merge it!

-Eoin


On Tue, Jun 11, 2013 at 9:35 AM, Josh Sharpe <josh.m.sharpe@gmail.com>wrote:

> You know... I think the setting of the hook, and some tests got
> backported, but the changes to worker.rb did not (or got blown away)
>
> ~/resque (v1.24.1) $ grep -R after_pause lib/ test/
> lib/resque.rb:  # Set the after_pause proc.
> lib/resque.rb:  # The `after_pause` hook will be run in the parent
> process after the
> lib/resque.rb:  def after_pause(&block)
> lib/resque.rb:    block ? register_hook(:after_pause, block) :
> hooks(:after_pause)
> lib/resque.rb:  attr_writer :after_pause
>
> ...nothing in worker.rb....  Wut?
>
> Anyways, I can't get the test suite running - could someone check that?
>
> Also, I just did this and am going to run off my fork for right now:
>
>
> 
https://github.com/crankharder/resque/commit/cb6de84520b6b5acf21b2d1534c5666cde483975
>
> ...which works.  All my files showed up after USR2. Holla.
>
> Josh
>
>
>
> On Tue, Jun 11, 2013 at 11:17 AM, Eoin Coffey <ecoffey@gmail.com> wrote:
> > Although as the author of that feature I thought I had backported it to
> > 1-x-stable :-)
> >
> >
> > On Tue, Jun 11, 2013 at 9:14 AM, Emil Kampp <emil@kampp.me> wrote:
> >>
> >>
> >> Hehe.. I love those instances, where one figures something out just
> after
> >> posting it :)
> >>
> >>
> >> Best regards / Venlig hilsen
> >>
> >> Emil Kampp
> >> Kampp Media
> >> Baltorpvej 189, st.-1, DK 2750
> >> emil.kampp.me | emil@kampp.me | +45 42427176 | CVR: DK30160983
> >>
> >> On Tuesday, June 11, 2013 at 5:12 PM, Josh Sharpe wrote:
> >>
> >> I'm gonna go ahead and answer this one:
> >>
> >> Because that method is on master, and not on 1.24.1.
> >>
> >> On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <josh.m.sharpe@gmail.com>
> >> wrote:
> >>
> >> I've been trying to get Resque#before_pause to work and it's not
> >> playing nice. I have a rails initializer that looks something like
> >> this:
> >>
> >> config/initializers/resque.rb:
> >>
> >> Resque.before_pause do |worker|
> >> File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
> >> f << $$
> >> end
> >> File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
> >> f << ENV['PIDFILE']
> >> end
> >> File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
> >> f << 'hello'
> >> e nd
> >> exit 1
> >> end
> >>
> >> Resque.after_fork do |worker|
> >> # raise 'dammit'
> >> defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
> >>
> >> Resque.redis = Redis.new(RedisConnection.configuration)
> >> end
> >>
> >>
> >> A couple of things about this initializer.
> >>
> >> 1) The #after_fork hook is definitely working. Uncommenting that
> >> first line raises obvious hell. Under normal circumstances I see
> >> stuff like this in the logs:
> >>
> >> *** Running before_fork hooks with....
> >> *** resque-1.24.1: Forked 14511 at 1370961746
> >> *** Running after_fork hooks
> >>
> >> .... and ActiveRecord::Base doesn't throw connection errors and such.
> >>
> >> 2) The before_pause *should* be raising hell (exit 1). And even if
> >> there was some permission issue on writing those files it should be
> >> blowing up, but there's nothing:
> >>
> >> Logs look something like this:
> >>
> >> *** resque-1.24.1: Processing high since 1370961746 [FooJob]
> >> *** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> >> *** resque-1.24.1: Forked 14511 at 1370961746
> >> *** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
> >> *** USR2 received; pausing job processing
> >> *** done: (Job{high} | FooJob | ["prk", {}])
> >> *** Sleeping for 5.0 seconds
> >> *** resque-1.24.1: Paused
> >> *** Sleeping for 5.0 seconds
> >> *** resque-1.24.1: Paused
> >> *** Sleeping for 5.0 seconds
> >> *** resque-1.24.1: Paused
> >>
> >> So there's the USR2, and the pausing works (there are more jobs on the
> >> queue not getting consume)... But before_hook wasn't executed.
> >>
> >> Thanks!
> >> Josh
> >>
> >>
> >
>

Re: [resque] Re: experiments with before_pause failing hard

From:
Josh Sharpe
Date:
2013-06-11 @ 15:42
I would, except the test suite doesn't run on 1.24.1:

uninitialized constant Mocha::MonkeyPatching

Fix that and I'll get you a PR for the hook problems.

On Tue, Jun 11, 2013 at 11:39 AM, Eoin Coffey <ecoffey@gmail.com> wrote:
> Yeah something got dropped in worker.rb for sure, nice catch.
>
> If you can beat me to the PR, I'll happily merge it!
>
> -Eoin
>
>
> On Tue, Jun 11, 2013 at 9:35 AM, Josh Sharpe <josh.m.sharpe@gmail.com>
> wrote:
>>
>> You know... I think the setting of the hook, and some tests got
>> backported, but the changes to worker.rb did not (or got blown away)
>>
>> ~/resque (v1.24.1) $ grep -R after_pause lib/ test/
>> lib/resque.rb:  # Set the after_pause proc.
>> lib/resque.rb:  # The `after_pause` hook will be run in the parent
>> process after the
>> lib/resque.rb:  def after_pause(&block)
>> lib/resque.rb:    block ? register_hook(:after_pause, block) :
>> hooks(:after_pause)
>> lib/resque.rb:  attr_writer :after_pause
>>
>> ...nothing in worker.rb....  Wut?
>>
>> Anyways, I can't get the test suite running - could someone check that?
>>
>> Also, I just did this and am going to run off my fork for right now:
>>
>>
>> 
https://github.com/crankharder/resque/commit/cb6de84520b6b5acf21b2d1534c5666cde483975
>>
>> ...which works.  All my files showed up after USR2. Holla.
>>
>> Josh
>>
>>
>>
>> On Tue, Jun 11, 2013 at 11:17 AM, Eoin Coffey <ecoffey@gmail.com> wrote:
>> > Although as the author of that feature I thought I had backported it to
>> > 1-x-stable :-)
>> >
>> >
>> > On Tue, Jun 11, 2013 at 9:14 AM, Emil Kampp <emil@kampp.me> wrote:
>> >>
>> >>
>> >> Hehe.. I love those instances, where one figures something out just
>> >> after
>> >> posting it :)
>> >>
>> >>
>> >> Best regards / Venlig hilsen
>> >>
>> >> Emil Kampp
>> >> Kampp Media
>> >> Baltorpvej 189, st.-1, DK 2750
>> >> emil.kampp.me | emil@kampp.me | +45 42427176 | CVR: DK30160983
>> >>
>> >> On Tuesday, June 11, 2013 at 5:12 PM, Josh Sharpe wrote:
>> >>
>> >> I'm gonna go ahead and answer this one:
>> >>
>> >> Because that method is on master, and not on 1.24.1.
>> >>
>> >> On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <josh.m.sharpe@gmail.com>
>> >> wrote:
>> >>
>> >> I've been trying to get Resque#before_pause to work and it's not
>> >> playing nice. I have a rails initializer that looks something like
>> >> this:
>> >>
>> >> config/initializers/resque.rb:
>> >>
>> >> Resque.before_pause do |worker|
>> >> File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
>> >> f << $$
>> >> end
>> >> File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
>> >> f << ENV['PIDFILE']
>> >> end
>> >> File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do |f|
>> >> f << 'hello'
>> >> e nd
>> >> exit 1
>> >> end
>> >>
>> >> Resque.after_fork do |worker|
>> >> # raise 'dammit'
>> >> defined?(ActiveRecord::Base) and
>> >> ActiveRecord::Base.establish_connection
>> >>
>> >> Resque.redis = Redis.new(RedisConnection.configuration)
>> >> end
>> >>
>> >>
>> >> A couple of things about this initializer.
>> >>
>> >> 1) The #after_fork hook is definitely working. Uncommenting that
>> >> first line raises obvious hell. Under normal circumstances I see
>> >> stuff like this in the logs:
>> >>
>> >> *** Running before_fork hooks with....
>> >> *** resque-1.24.1: Forked 14511 at 1370961746
>> >> *** Running after_fork hooks
>> >>
>> >> .... and ActiveRecord::Base doesn't throw connection errors and such.
>> >>
>> >> 2) The before_pause *should* be raising hell (exit 1). And even if
>> >> there was some permission issue on writing those files it should be
>> >> blowing up, but there's nothing:
>> >>
>> >> Logs look something like this:
>> >>
>> >> *** resque-1.24.1: Processing high since 1370961746 [FooJob]
>> >> *** Running before_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
>> >> *** resque-1.24.1: Forked 14511 at 1370961746
>> >> *** Running after_fork hooks with [(Job{high} | FooJob | ["prk", {}])]
>> >> *** USR2 received; pausing job processing
>> >> *** done: (Job{high} | FooJob | ["prk", {}])
>> >> *** Sleeping for 5.0 seconds
>> >> *** resque-1.24.1: Paused
>> >> *** Sleeping for 5.0 seconds
>> >> *** resque-1.24.1: Paused
>> >> *** Sleeping for 5.0 seconds
>> >> *** resque-1.24.1: Paused
>> >>
>> >> So there's the USR2, and the pausing works (there are more jobs on the
>> >> queue not getting consume)... But before_hook wasn't executed.
>> >>
>> >> Thanks!
>> >> Josh
>> >>
>> >>
>> >
>
>

Re: [resque] Re: experiments with before_pause failing hard

From:
Eoin Coffey
Date:
2013-06-11 @ 15:45
That has to be one of the more ironic `uninitialized constant` errors :-)

I'll try to dig into this before EOD, and let you know :-)

Thanks again!

-Eoin


On Tue, Jun 11, 2013 at 9:42 AM, Josh Sharpe <josh.m.sharpe@gmail.com>wrote:

> I would, except the test suite doesn't run on 1.24.1:
>
> uninitialized constant Mocha::MonkeyPatching
>
> Fix that and I'll get you a PR for the hook problems.
>
> On Tue, Jun 11, 2013 at 11:39 AM, Eoin Coffey <ecoffey@gmail.com> wrote:
> > Yeah something got dropped in worker.rb for sure, nice catch.
> >
> > If you can beat me to the PR, I'll happily merge it!
> >
> > -Eoin
> >
> >
> > On Tue, Jun 11, 2013 at 9:35 AM, Josh Sharpe <josh.m.sharpe@gmail.com>
> > wrote:
> >>
> >> You know... I think the setting of the hook, and some tests got
> >> backported, but the changes to worker.rb did not (or got blown away)
> >>
> >> ~/resque (v1.24.1) $ grep -R after_pause lib/ test/
> >> lib/resque.rb:  # Set the after_pause proc.
> >> lib/resque.rb:  # The `after_pause` hook will be run in the parent
> >> process after the
> >> lib/resque.rb:  def after_pause(&block)
> >> lib/resque.rb:    block ? register_hook(:after_pause, block) :
> >> hooks(:after_pause)
> >> lib/resque.rb:  attr_writer :after_pause
> >>
> >> ...nothing in worker.rb....  Wut?
> >>
> >> Anyways, I can't get the test suite running - could someone check that?
> >>
> >> Also, I just did this and am going to run off my fork for right now:
> >>
> >>
> >>
> 
https://github.com/crankharder/resque/commit/cb6de84520b6b5acf21b2d1534c5666cde483975
> >>
> >> ...which works.  All my files showed up after USR2. Holla.
> >>
> >> Josh
> >>
> >>
> >>
> >> On Tue, Jun 11, 2013 at 11:17 AM, Eoin Coffey <ecoffey@gmail.com>
> wrote:
> >> > Although as the author of that feature I thought I had backported it
> to
> >> > 1-x-stable :-)
> >> >
> >> >
> >> > On Tue, Jun 11, 2013 at 9:14 AM, Emil Kampp <emil@kampp.me> wrote:
> >> >>
> >> >>
> >> >> Hehe.. I love those instances, where one figures something out just
> >> >> after
> >> >> posting it :)
> >> >>
> >> >>
> >> >> Best regards / Venlig hilsen
> >> >>
> >> >> Emil Kampp
> >> >> Kampp Media
> >> >> Baltorpvej 189, st.-1, DK 2750
> >> >> emil.kampp.me | emil@kampp.me | +45 42427176 | CVR: DK30160983
> >> >>
> >> >> On Tuesday, June 11, 2013 at 5:12 PM, Josh Sharpe wrote:
> >> >>
> >> >> I'm gonna go ahead and answer this one:
> >> >>
> >> >> Because that method is on master, and not on 1.24.1.
> >> >>
> >> >> On Tue, Jun 11, 2013 at 10:54 AM, Josh Sharpe <
> josh.m.sharpe@gmail.com>
> >> >> wrote:
> >> >>
> >> >> I've been trying to get Resque#before_pause to work and it's not
> >> >> playing nice. I have a rails initializer that looks something like
> >> >> this:
> >> >>
> >> >> config/initializers/resque.rb:
> >> >>
> >> >> Resque.before_pause do |worker|
> >> >> File.open("/tmp/resque_before_pause_test_#{$$}", "w+") do |f|
> >> >> f << $$
> >> >> end
> >> >> File.open("/tmp/resque_env_pid_file_#{$$}", "w+") do |f|
> >> >> f << ENV['PIDFILE']
> >> >> end
> >> >> File.open("/u/apps/stocks/current/pids/footest_#{$$}.txt", "w+") do
> |f|
> >> >> f << 'hello'
> >> >> e nd
> >> >> exit 1
> >> >> end
> >> >>
> >> >> Resque.after_fork do |worker|
> >> >> # raise 'dammit'
> >> >> defined?(ActiveRecord::Base) and
> >> >> ActiveRecord::Base.establish_connection
> >> >>
> >> >> Resque.redis = Redis.new(RedisConnection.configuration)
> >> >> end
> >> >>
> >> >>
> >> >> A couple of things about this initializer.
> >> >>
> >> >> 1) The #after_fork hook is definitely working. Uncommenting that
> >> >> first line raises obvious hell. Under normal circumstances I see
> >> >> stuff like this in the logs:
> >> >>
> >> >> *** Running before_fork hooks with....
> >> >> *** resque-1.24.1: Forked 14511 at 1370961746
> >> >> *** Running after_fork hooks
> >> >>
> >> >> .... and ActiveRecord::Base doesn't throw connection errors and such.
> >> >>
> >> >> 2) The before_pause *should* be raising hell (exit 1). And even if
> >> >> there was some permission issue on writing those files it should be
> >> >> blowing up, but there's nothing:
> >> >>
> >> >> Logs look something like this:
> >> >>
> >> >> *** resque-1.24.1: Processing high since 1370961746 [FooJob]
> >> >> *** Running before_fork hooks with [(Job{high} | FooJob | ["prk",
> {}])]
> >> >> *** resque-1.24.1: Forked 14511 at 1370961746
> >> >> *** Running after_fork hooks with [(Job{high} | FooJob | ["prk",
> {}])]
> >> >> *** USR2 received; pausing job processing
> >> >> *** done: (Job{high} | FooJob | ["prk", {}])
> >> >> *** Sleeping for 5.0 seconds
> >> >> *** resque-1.24.1: Paused
> >> >> *** Sleeping for 5.0 seconds
> >> >> *** resque-1.24.1: Paused
> >> >> *** Sleeping for 5.0 seconds
> >> >> *** resque-1.24.1: Paused
> >> >>
> >> >> So there's the USR2, and the pausing works (there are more jobs on
> the
> >> >> queue not getting consume)... But before_hook wasn't executed.
> >> >>
> >> >> Thanks!
> >> >> Josh
> >> >>
> >> >>
> >> >
> >
> >
>

Re: [resque] Re: experiments with before_pause failing hard

From:
Steve Klabnik
Date:
2013-06-11 @ 15:50
Ahahahah oh man that error message.

Re: [resque] Re: experiments with before_pause failing hard

From:
Eoin Coffey
Date:
2013-06-11 @ 15:59
Do you have any insight into that particular error Steve?


On Tue, Jun 11, 2013 at 9:50 AM, Steve Klabnik <steve@steveklabnik.com>wrote:

> Ahahahah oh man that error message.
>

Re: [resque] Re: experiments with before_pause failing hard

From:
Steve Klabnik
Date:
2013-06-11 @ 16:04
Nope, never seen it before.