Skip to content

Commit

Permalink
increase the startup timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsiaw committed May 10, 2024
1 parent 6798ab4 commit e746ab6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-run-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: workaround
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
Expand Down
14 changes: 9 additions & 5 deletions dockerfiles/run-pack/watch_interactive_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
ps "github.com/mitchellh/go-ps"
)

const StartupTimeoutSeconds = 3 * 60
const RunTimeoutHours = 24
const TickIntervalSeconds = 5

func otherSessionRunning(processes []ps.Process) (ps.Process, error) {
for _, p := range processes {
// pid == 1: the process was spawned by `docker run` command
Expand All @@ -27,9 +31,9 @@ func otherSessionRunning(processes []ps.Process) (ps.Process, error) {
func watchInteractiveSession() {
log.Println("Interactive run watcher started")

startTimeout := time.After(30 * time.Second)
runTimeout := time.After(24 * time.Hour)
tick := time.Tick(5 * time.Second)
startTimeout := time.After(StartupTimeoutSeconds * time.Second)
runTimeout := time.After(RunTimeoutHours * time.Hour)
tick := time.Tick(TickIntervalSeconds * time.Second)
sessionStarted := false
for {
select {
Expand All @@ -54,11 +58,11 @@ func watchInteractiveSession() {
}
case <-startTimeout:
if !sessionStarted {
log.Println("Interactive session has not started for 30 seconds")
log.Printf("Interactive session has not started for %d seconds", StartupTimeoutSeconds)
os.Exit(2)
}
case <-runTimeout:
log.Println("Interactive session has run for over 24 hours")
log.Printf("Interactive session has run for over %d hours", RunTimeoutHours)
os.Exit(2)
}
}
Expand Down

0 comments on commit e746ab6

Please sign in to comment.