Skip to content

Commit b092604

Browse files
committed
fix: multiple fixes for excessive cpu consumption
The tray menu was not cleaning up properly.
1 parent e3b641e commit b092604

File tree

5 files changed

+36
-23
lines changed

5 files changed

+36
-23
lines changed

Diff for: package-lock.json

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: plugins/plugin-codeflare/src/tray/menus/profiles/tasks.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ import logAggregator from "./log-aggregator"
2525

2626
export default function tasks(profile: string, createWindow: CreateWindowFunction): MenuItemConstructorOptions[] {
2727
return [
28-
boot(profile, createWindow),
2928
shutdown(profile, createWindow),
3029
{
3130
label: "Advanced",
32-
submenu: [...section("Log Aggregator", logAggregator(profile, createWindow))],
31+
submenu: [boot(profile, createWindow), ...section("Log Aggregator", logAggregator(profile, createWindow))],
3332
},
3433
]
3534
}

Diff for: plugins/plugin-codeflare/src/tray/watchers/profile/active-runs.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,28 @@ export default class ProfileActiveRunWatcher {
4747
private static async initWatcher(profile: string) {
4848
const guidebook = "ml/ray/cluster/connect"
4949
try {
50+
const { app } = await import("electron")
51+
const registerCleanup = ({ cleanExit }: { cleanExit: () => void }) => {
52+
const onExit = () => cleanExit()
53+
process.on("exit", onExit)
54+
process.on("SIGINT", onExit) // catch ctrl-c
55+
process.on("SIGTERM", onExit) // catch kill
56+
57+
// use the electron API to register our onExit handler
58+
app.on("before-quit", onExit)
59+
}
60+
5061
const resp = await cli(["madwizard", "guide", guidebook], undefined, {
5162
profile,
5263
bump: false, // don't bump the lastUsedTime of the profile
5364
clean: false, // don't kill the port-forward subprocess! we'll manage that
5465
interactive: false,
5566
store: process.env.GUIDEBOOK_STORE,
67+
onBeforeRun: registerCleanup, // use this hook to register our electron-based cleanup hook
5668
})
5769

5870
if (resp) {
59-
if (resp.cleanExit) {
60-
process.on("exit", () => resp.cleanExit())
61-
}
71+
registerCleanup(resp)
6272

6373
if (resp.env && typeof resp.env.RAY_ADDRESS === "string") {
6474
return resp.env.RAY_ADDRESS

Diff for: plugins/plugin-codeflare/src/tray/watchers/profile/status.ts

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ export default class ProfileStatusWatcher {
110110
process.on("SIGINT", onExit) // catch ctrl-c
111111
process.on("SIGTERM", onExit) // catch kill
112112

113+
// use the electron API to register our onExit handler
114+
const { app } = await import("electron")
115+
app.on("before-quit", onExit)
116+
113117
job.on("error", () => {
114118
Debug("codeflare")("Watcher error", profile)
115119
this.headReadiness = "error"

Diff for: plugins/plugin-madwizard/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^1.8.5",
27-
"@guidebooks/store": "^0.18.0"
26+
"madwizard": "^1.9.0",
27+
"@guidebooks/store": "^0.18.1"
2828
}
2929
}

0 commit comments

Comments
 (0)