I'm trying a different approach to autoscaling workers in my heroku
app.
I'm using a custom config variable in my heroku config I've labeled
'WORKER_COUNT', which represents how many workers are running
currently. I've also added HEROKU_USERNAME, HEROKU_PASSWORD, and
HEROKU_APP to my heroku config.
I added "require 'heroku'" at the beginning of my application
controller, and a method to add a worker and increment 'WORKER_COUNT'
by one...:
def add_heroku_worker
heroku = Heroku::Client.new(ENV['HEROKU_USERNAME'],
ENV['HEROKU_PASSWORD'])
myapp = heroku(ENV['HEROKU_APP'])
worker_count = heroku(ENV['WORKER_COUNT'])
qty = worker_count + 1
heroku.add_config_vars(myapp, {"WORKER_COUNT" => qty})
heroku.set_workers(ENV['HEROKU_APP'], qty)
end
...and another method (called 'subtract_heroku_worker') to subtract a
worker and deprecate 'WORKER_COUNT' by one.
I call add_heroku_worker right after delaying a job...:
@job.delay.import(path)
add_heroku_worker
...and subtract_heroku_worker right after the job sucessfully
completes.
Problem is, nothing seems to be happening. I get no errors, but no
workers, either. I suspect either my syntax is wrong, or I'm just
going about this the wrong way.
Can anybody help shed some light on this?
--
You received this message because you are subscribed to the Google Groups
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/heroku?hl=en.