rohitpaulk rohitpaulk - 5 months ago 157
Ruby Question

How do I access the exit code of a heroku one-off dyno?

I'm using heroku's platform API + the rendezvous client to execute a command and retrieve it's output + exit code.

def run_command(heroku_client, app_name, command)
dyno = heroku_client.dyno.create(app_name, command: command, attach: true)

rendezvous_url = dyno["attach_url"]

rz ={,,
url: rendezvous_url

rz.start # Blocks until the command completes


I can fetch the output just fine, as shown above. I can't find a way to access the exit code though. I tried fetching
from the API after the process has exited, but I get a

Answer Source

Heroku doesn't support retrieving exit codes from a one-off dyno. One way to achieve this would be to use my_command; echo $? and then parse out the exit code manually. This gem has a plugin that does that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download