Skip to content

Commit

Permalink
fix: multiple fixes for excessive cpu consumption
Browse files Browse the repository at this point in the history
The tray menu was not cleaning up properly.
  • Loading branch information
starpit committed Nov 22, 2022
1 parent e3b641e commit b092604
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions plugins/plugin-codeflare/src/tray/menus/profiles/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import logAggregator from "./log-aggregator"

export default function tasks(profile: string, createWindow: CreateWindowFunction): MenuItemConstructorOptions[] {
return [
boot(profile, createWindow),
shutdown(profile, createWindow),
{
label: "Advanced",
submenu: [...section("Log Aggregator", logAggregator(profile, createWindow))],
submenu: [boot(profile, createWindow), ...section("Log Aggregator", logAggregator(profile, createWindow))],
},
]
}
16 changes: 13 additions & 3 deletions plugins/plugin-codeflare/src/tray/watchers/profile/active-runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,28 @@ export default class ProfileActiveRunWatcher {
private static async initWatcher(profile: string) {
const guidebook = "ml/ray/cluster/connect"
try {
const { app } = await import("electron")
const registerCleanup = ({ cleanExit }: { cleanExit: () => void }) => {
const onExit = () => cleanExit()
process.on("exit", onExit)
process.on("SIGINT", onExit) // catch ctrl-c
process.on("SIGTERM", onExit) // catch kill

// use the electron API to register our onExit handler
app.on("before-quit", onExit)
}

const resp = await cli(["madwizard", "guide", guidebook], undefined, {
profile,
bump: false, // don't bump the lastUsedTime of the profile
clean: false, // don't kill the port-forward subprocess! we'll manage that
interactive: false,
store: process.env.GUIDEBOOK_STORE,
onBeforeRun: registerCleanup, // use this hook to register our electron-based cleanup hook
})

if (resp) {
if (resp.cleanExit) {
process.on("exit", () => resp.cleanExit())
}
registerCleanup(resp)

if (resp.env && typeof resp.env.RAY_ADDRESS === "string") {
return resp.env.RAY_ADDRESS
Expand Down
4 changes: 4 additions & 0 deletions plugins/plugin-codeflare/src/tray/watchers/profile/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export default class ProfileStatusWatcher {
process.on("SIGINT", onExit) // catch ctrl-c
process.on("SIGTERM", onExit) // catch kill

// use the electron API to register our onExit handler
const { app } = await import("electron")
app.on("before-quit", onExit)

job.on("error", () => {
Debug("codeflare")("Watcher error", profile)
this.headReadiness = "error"
Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin-madwizard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"access": "public"
},
"dependencies": {
"madwizard": "^1.8.5",
"@guidebooks/store": "^0.18.0"
"madwizard": "^1.9.0",
"@guidebooks/store": "^0.18.1"
}
}

0 comments on commit b092604

Please sign in to comment.