Search code examples
herokuheroku-api

Heroku API: capture output of a command run on a one-off dyno


How do I capture the output of a command being run on a one-off dyno via the API?

For example:

heroku = PlatformAPI.connect("...")

heroku.dyno.create(
  app_name,
  attach: false,
  command: "ls"
)

This just returns the dyno creation response. It does not include the output of the command.


Solution

  • If you set the attach argument to true, it will stream the output. To actually get the stream, you should look at the response to dyno create and find the value of attach_url. You should be able to pass this to a rendezvous client (like the rendezvous gem) to read info, more details on that here: https://github.com/heroku/rendezvous.rb