Skip to content

Commit

Permalink
terminate dyno via API on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dzuelke committed Jan 24, 2023
1 parent 83d6744 commit 81c6fde
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Timeout support for 'heroku run' (in case of networking, hanging or "server boot" tests etc), defaults to 60 s, global override `$HATCHET_DEFAULT_RUN_TIMEOUT`, per-test option `:timeout`
- Delay for empty/timeout retries if run_multi is off, defaults to 1 s, global override `$HATCHET_RUN_RETRY_DELAY`
- Record and print dyno id ("run.1234") in event of empty output or timeout retry
- Terminate dyno via API on timeout

## 7.4.0

Expand Down
3 changes: 2 additions & 1 deletion lib/hatchet/heroku_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ def call
rescue HerokuRunTimeoutError => e
if @timeout_fail_count < 3
@timeout_fail_count += 1
message = String.new("Run #{@dyno_id} with command #{@command} timed out after #{@timeout} seconds, retrying...")
message = String.new("Run #{@dyno_id} with command #{@command} timed out after #{@timeout} seconds, stopping dyno and retrying...")
message << "\nstderr until moment of termination was: #{@result.stderr}"
message << "\nstdout until moment of termination was: #{@result.stdout}"
message << "\nTo disable pass in `timeout: 0` or set HATCHET_DEFAULT_RUN_TIMEOUT=0 globally"
message << "\nfailed_count: #{@timeout_fail_count}"
message << "\nreleases: #{@app.releases}"
message << "\n#{caller.join("\n")}"
@stderr.puts message
@app.platform_api.dyno.stop(@app.name, @dyno_id) if @dyno_id
sleep(@retry_delay) # without run_multi, this will prevent occasional "can only run one free dyno" errors
retry
end
Expand Down

0 comments on commit 81c6fde

Please sign in to comment.