Skip to content

Commit 270db08

Browse files
committed
feat: add skip-cleanup flag and fix api-proxy shutdown
Add --skip-cleanup CLI flag to skip cleanup operations in CI environments where the runner terminates anyway, saving ~10 seconds per workflow run. Changes: - Add skipCleanup option to WrapperConfig interface - Add --skip-cleanup CLI flag with documentation - Skip container stop, iptables cleanup, and workdir removal when enabled - Fix api-proxy Dockerfile to use exec form CMD for instant SIGTERM response The api-proxy container previously used shell form CMD with tee pipeline, causing 10s timeout on shutdown. Now uses exec form so Node.js becomes PID 1 and handles SIGTERM gracefully.
1 parent 0f68cbd commit 270db08

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

containers/api-proxy/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ USER apiproxy
3030
# 10004 - OpenCode API proxy (routes to Anthropic)
3131
EXPOSE 10000 10001 10002 10004
3232

33-
# Redirect stdout/stderr to log file for persistence
34-
# Use shell form to enable redirection and tee for both file and console
35-
CMD node server.js 2>&1 | tee -a /var/log/api-proxy/api-proxy.log
33+
# Use exec form so Node.js is PID 1 and receives SIGTERM directly
34+
# Docker captures stdout/stderr automatically, no need for manual log redirection
35+
CMD ["node", "server.js"]

src/cli.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,11 @@ program
696696
'Keep containers running after command exits',
697697
false
698698
)
699+
.option(
700+
'--skip-cleanup',
701+
'Skip all cleanup (containers, iptables, work dir) - useful in CI where runner terminates anyway',
702+
false
703+
)
699704
.option(
700705
'--tty',
701706
'Allocate a pseudo-TTY for the container (required for interactive tools like Claude Code)',
@@ -1062,6 +1067,7 @@ program
10621067
agentCommand,
10631068
logLevel,
10641069
keepContainers: options.keepContainers,
1070+
skipCleanup: options.skipCleanup,
10651071
tty: options.tty || false,
10661072
workDir: options.workDir,
10671073
buildLocal: options.buildLocal,
@@ -1180,6 +1186,12 @@ program
11801186
logger.info(`Received ${signal}, cleaning up...`);
11811187
}
11821188

1189+
// Skip all cleanup if requested (useful in CI where runner terminates anyway)
1190+
if (config.skipCleanup) {
1191+
logger.info('Skipping cleanup (--skip-cleanup enabled)');
1192+
return;
1193+
}
1194+
11831195
if (containersStarted) {
11841196
await stopContainers(config.workDir, config.keepContainers);
11851197
}

src/types.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ export interface WrapperConfig {
131131
*/
132132
keepContainers: boolean;
133133

134+
/**
135+
* Whether to skip cleanup when the process exits
136+
*
137+
* When true:
138+
* - Containers are not stopped (left running or stopped by Docker daemon)
139+
* - Host iptables rules are not cleaned up
140+
* - Work directory is not deleted
141+
* - Useful in CI environments where the runner will terminate anyway,
142+
* saving ~10 seconds of shutdown time
143+
*
144+
* This is a stronger version of keepContainers that also skips all cleanup
145+
* operations, not just container removal.
146+
*
147+
* @default false
148+
*/
149+
skipCleanup?: boolean;
150+
134151
/**
135152
* Whether to allocate a pseudo-TTY for the agent execution container
136153
*

0 commit comments

Comments
 (0)