0
我正在使用heroku的平臺API +集合點客戶端執行命令並檢索它的輸出+退出代碼。如何訪問heroku一次性動態碼的退出碼?
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
我可以提取輸出就好了,如上所示。雖然我找不到訪問退出代碼的方法。在進程退出後,我試圖從API中獲取dyno.info
,但我得到了一個404
。
我現在的解決方法是使用'my_command; echo $?',然後手動解析出口代碼。 – rohitpaulk
剛剛找到了一個相同的寶石:https://github.com/glenngillen/heroku-exit-status/blob/master/lib/heroku/exit-status.rb – rohitpaulk