开发者

Heroku REST API - Is there any?

Is there a Heroku API that allows me to scale up and down my dynos programmati开发者_如何学Pythoncally, etc?

I've found the link for the API docs but it seems that it doesn't exist anymore.

Thanks


This link works at this time for the API. For autoscaling we use hirefire. That's a hosted service which is slightly more capable than the open source gem by the same name.


The Heroku gem allows you to add and remove processes easily.

gem "heroku"

You can create a client in ruby that can set the number of workers or dynos, etc

client = Heroku::Client.new(username, password)
client.list  # provides a list of heroku apps
client.info(app) # provides info on the particular app, including dynos and workers
client.workers(app) # returns the number of workers currently running for the app
client.set_workers(app, qty) # sets the number of workers for the app
client.dynos(app) # returns the number of dynos currently running for the app
client.set_dynos(app, qty) # sets the number of dynos

Basically, anything you can do from the command line, you can do with the gem.

Checkout https://github.com/heroku/heroku/blob/master/lib/heroku/client.rb for details.


It appears Heroku::Client is deprecated now. heroku-api gem has the ability you need. https://github.com/heroku/heroku.rb


I'm not sure there's anything documented but the heroku gem itself talks to their API over REST so you can take a peak inside that.

There are auto scaling gems out there for Heroku and I've seen other examples where you include the Heroku gem into your own app to be able to interface to their API without getting too involved of the guts of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜