Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 09e1141

Browse files
committed
Add reason field to restart logs
1 parent 8db677d commit 09e1141

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/server/runtime/deno/AppsEngineDenoRuntime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
271271

272272
// When an app has just been installed, the status in the storageItem passed to this controller will be "initialized"
273273
// So, whenever we get that value here, let's just make it 'auto_enabled'
274-
let status = this.storageItem.status;
274+
let { status } = this.storageItem;
275275

276276
if (status === AppStatus.INITIALIZED) {
277277
logger.info('Stored status was "initialized". Changing to "auto_enabled"');

src/server/runtime/deno/LivenessManager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class LivenessManager {
132132

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

@@ -164,17 +164,21 @@ export class LivenessManager {
164164
return;
165165
}
166166

167+
let reason: string;
168+
167169
// Otherwise we try to restart the subprocess, if possible
168170
if (signal) {
169171
this.debug('App has been killed (%s). Attempting restart #%d...', signal, this.restartCount + 1);
172+
reason = `App has been killed with signal ${signal}`;
170173
} else {
171174
this.debug('App has exited with code %d. Attempting restart #%d...', exitCode, this.restartCount + 1);
175+
reason = `App has exited with code ${exitCode}`;
172176
}
173177

174-
this.restartProcess();
178+
this.restartProcess(reason);
175179
}
176180

177-
private restartProcess() {
181+
private restartProcess(reason: string) {
178182
if (this.restartCount >= this.options.maxRestarts) {
179183
this.debug('Limit of restarts reached (%d). Aborting restart...', this.options.maxRestarts);
180184
this.controller.stopApp();
@@ -184,6 +188,7 @@ export class LivenessManager {
184188
this.pingTimeoutConsecutiveCount = 0;
185189
this.restartCount++;
186190
this.restartLog.push({
191+
reason,
187192
restartedAt: new Date(),
188193
source: 'liveness-manager',
189194
pid: this.subprocess.pid,

0 commit comments

Comments
 (0)