Skip to content

Commit d4b4a59

Browse files
committed
fix: make service ready timeout configurable via env var
The DefaultServiceTimeout constant is hard-coded to 5 seconds, which causes the inspect-server (and occasionally other services) to be killed by the supervisor before they finish initialising on slow or resource-constrained environments such as fly.io. Replace the constant with a package-level var that reads CARTESI_SERVICE_READY_TIMEOUT from the environment at process start. The value must be a valid Go duration string (e.g. "30s", "1m"). If the variable is absent or invalid the original 5-second default is preserved, so the change is fully backward-compatible. Tested on fly.io: inspect-server takes ~21 s to become ready; with CARTESI_SERVICE_READY_TIMEOUT=30s all services report ready and the node runs normally.
1 parent 0e65d06 commit d4b4a59

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

internal/services/supervisor.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ import (
77
"context"
88
"errors"
99
"log/slog"
10+
"os"
1011
"time"
1112

1213
"golang.org/x/sync/errgroup"
1314
)
1415

15-
const DefaultServiceTimeout = 5 * time.Second
16+
const defaultServiceTimeoutSeconds = 5
17+
18+
var DefaultServiceTimeout = func() time.Duration {
19+
if v := os.Getenv("CARTESI_SERVICE_READY_TIMEOUT"); v != "" {
20+
if d, err := time.ParseDuration(v); err == nil && d > 0 {
21+
return d
22+
}
23+
}
24+
return defaultServiceTimeoutSeconds * time.Second
25+
}()
1626

1727
var (
1828
ServiceTimeoutError = errors.New("timed out waiting for service to be ready")

0 commit comments

Comments
 (0)