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 = Rendezvous.new({
input:StringIO.new,
output:StringIO.new,
url: rendezvous_url
})
rz.start # Blocks until the command completes
rz.output.rewind
rz.output.readlines.join
end
dyno.info
404
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.