Skip to content

Commit

Permalink
fix(processes): make failing status more forgiving
Browse files Browse the repository at this point in the history
  • Loading branch information
Qu4k committed May 23, 2020
1 parent 31cbbe0 commit 0e900ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/denon.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"logger": {
"fullscreen": true
"debug": true
},
"watcher": {
"exts": ["ts", "json", "ini"],
Expand Down
28 changes: 18 additions & 10 deletions src/daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,28 @@ export class Daemon implements AsyncIterable<DenonEvent> {
}

private async monitor(process: Deno.Process) {
const s = await process.status();
let p = this.#processes[process.pid];
const pid = process.pid;
let s: Deno.ProcessStatus | undefined;
try {
s = await process.status();
} catch (error) {
log.debug(error);
}
let p = this.#processes[pid];
if (p) {
// process exited on its own, so we should wait a reload
// remove it from processes array as it is already dead
delete this.#processes[process.pid];
delete this.#processes[pid];

// log status status
if (s.success) {
log.info("clean exit - waiting for changes before restart");
} else {
log.info(
"app crashed - waiting for file changes before starting ...",
);
if (s) {
// log status status
if (s.success) {
log.info("clean exit - waiting for changes before restart");
} else {
log.info(
"app crashed - waiting for file changes before starting ...",
);
}
}
}
}
Expand Down

0 comments on commit 0e900ad

Please sign in to comment.