Skip to content

Commit 13fb464

Browse files
committed
fix: codeflare dashboard --attach does not clean up on ctrl+c
1 parent 31e2ab0 commit 13fb464

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Diff for: plugins/plugin-codeflare/src/controller/attach.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export async function attach(
112112
*
113113
* @return the local logdir for the run
114114
*/
115-
export default async function attachCommand(args: Arguments<Options>) {
115+
export default async function attachCommand(args: Arguments<Options>, wait = args.parsedOptions.wait) {
116116
const jobId = args.parsedOptions.a
117117
const store = args.parsedOptions.s || process.env.GUIDEBOOK_STORE
118118
const profile = args.parsedOptions.p || (await import("madwizard").then((_) => _.Profiles.lastUsed()))
@@ -126,13 +126,14 @@ export default async function attachCommand(args: Arguments<Options>) {
126126
process.once("exit", () => {
127127
console.error("attach exit")
128128
})
129-
if (args.parsedOptions.wait) {
129+
if (wait) {
130130
await new Promise<void>((resolve) => {
131-
process.once("SIGTERM", () => {
132-
console.error("attach sigterm")
133-
cleanExit("SIGTERM")
134-
resolve()
135-
})
131+
["SIGINT" as const, "SIGTERM" as const].forEach((signal) =>
132+
process.once(signal, () => {
133+
cleanExit(signal)
134+
resolve()
135+
})
136+
)
136137
})
137138
}
138139
} else {

Diff for: plugins/plugin-codeflare/src/controller/dashboard.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const followFlags: CommandOptions["flags"] = {
4444
async function dashboardcli(args: Arguments<DashboardOptions>) {
4545
if (args.parsedOptions.attach) {
4646
// attach to a running job
47-
const logdir = await import("./attach").then((_) => _.default(args))
47+
const logdir = await import("./attach").then((_) => _.default(args, true))
4848
return args.REPL.qexec(`codeflare dashboardui -f ${encodeComponent(logdir)}`)
4949
}
5050

0 commit comments

Comments
 (0)