0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Heroku をAPI から操作して、worker の起動・停止を行う

0
Last updated at Posted at 2019-04-15

PlatformAPI を使うと、Rails から Heroku をAPIで制御できる。

簡単なことだが、platform-api の dyno と formation で混乱したのでメモ。

heroku = PlatformAPI.connect_oauth(ENV['HEROKU_OAUTH_TOKEN'])
heroku.formation.update('my-app', 'worker', {quantity:   num}) 

Dyno ではない

heroku の dyno を操作するのかと思って、エラーに対して auth を調べていたが、関係なかった。

heroku.dyno.stop('my-app', dyno_id) 

起動数を設定

{quantity:   num}

の num には、起動数をいれる。

1つで起動する場合は

heroku.formation.update('my-app', 'worker', {quantity:   1}) 

停止の場合は

heroku.formation.update('my-app', 'worker', {quantity:   0}) 

PlatformAPI

Heroku Dev Center
https://devcenter.heroku.com/articles/platform-api-quickstart

Ruby HTTP client for the Heroku API
https://github.com/heroku/platform-api

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?