Skip to content

Commit

Permalink
chore: add reason to app restart log (#33930)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert authored Nov 11, 2024
1 parent fd7eb76 commit 5c3b6b9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/apps-engine/src/server/runtime/deno/LivenessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class LivenessManager {

if (reason === 'timeout' && this.pingTimeoutConsecutiveCount >= this.options.consecutiveTimeoutLimit) {
this.debug('Subprocess failed to respond to pings %d consecutive times. Attempting restart...', this.options.consecutiveTimeoutLimit);
this.restartProcess();
this.restartProcess('Too many pings timed out');
return false;
}

Expand Down Expand Up @@ -164,17 +164,21 @@ export class LivenessManager {
return;
}

let reason: string;

// Otherwise we try to restart the subprocess, if possible
if (signal) {
this.debug('App has been killed (%s). Attempting restart #%d...', signal, this.restartCount + 1);
reason = `App has been killed with signal ${signal}`;
} else {
this.debug('App has exited with code %d. Attempting restart #%d...', exitCode, this.restartCount + 1);
reason = `App has exited with code ${exitCode}`;
}

this.restartProcess();
this.restartProcess(reason);
}

private restartProcess() {
private restartProcess(reason: string) {
if (this.restartCount >= this.options.maxRestarts) {
this.debug('Limit of restarts reached (%d). Aborting restart...', this.options.maxRestarts);
this.controller.stopApp();
Expand All @@ -184,6 +188,7 @@ export class LivenessManager {
this.pingTimeoutConsecutiveCount = 0;
this.restartCount++;
this.restartLog.push({
reason,
restartedAt: new Date(),
source: 'liveness-manager',
pid: this.subprocess.pid,
Expand Down

0 comments on commit 5c3b6b9

Please sign in to comment.