Search code examples
rubyherokurakerake-taskrakefile

Rake tasks for scaling ruby apps in Heroku (non-rails)?


I'm currently running a ruby app with:

heroku scale web=0
heroku scale worker=1

I'd like to write a rake task that will run:

heroku scale worker=0

I'm thinking of something akin to:

task :scale_down => :environment do
  heroku = Heroku::API.new
  heroku.post_ps_scale('worker', 0)
end

but one problem is that my app doesn't have an environment since it's not a rails app. Is there a simple rake task that I can use to scale my worker to 0? Thanks!


Solution

  • task :scale_down do
      heroku = Heroku::API.new(api_key: ENV['HEROKU_API_KEY'])
      heroku.post_ps_scale(ENV['APP_NAME'], 'worker', 0)
    end
    

    This scales the app down to 0. May want to assign that number to a config var..