Worker only starts with more than one job on queue? #29

Closed
fixr opened this Issue Oct 10, 2012 · 3 comments

Projects

None yet

3 participants

@fixr

Testing an app on the Cedar stack, seems like the worker only starts after a second job is added to the queue, both setting the MIN/MAX/RATIO configs and not. Is this the expected behavior?

I'm using:

workless 1.1.0
delayed_job 3.x
ruby 1.9.2
rails 3.2.7
heroku-api

Also: local works fine.

Thanks!

@fixr

Browsing the code, I think that maybe the issue was introduced here: https://github.com/lostboy/workless/blob/3767b3d4c06973a96d6f00b7e7461bb7ab9ce07e/lib/workless/scalers/heroku_cedar.rb

Before:

client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => 1) if self.workers == 0

After:

client.ps_scale(ENV['APP_NAME'], :type => 'worker', :qty => self.workers_needed) if self.workers < self.workers_needed

I might be wrong, but my guess is that self.workers_needed returns '0' the first time around becuase it's hooked before the insertion is made, so self.jobs.count is still 0 at that point.

@filiptepper

Looks like you've nailed it, @fixr!

@lostboy, I've checked my patch on Heroku, seems to be working as expected. Could you merge and release? Thanks!

@lostboy
Owner

@filiptepper , @fixr so it should be reverted to the original 'before' state? do you want to submit a pr so i don't bodge it?

@lostboy lostboy pushed a commit that closed this issue Oct 13, 2012
Filip Tepper spawn workers after_create
fixes #29
4343492
@lostboy lostboy closed this in 4343492 Oct 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment