Skip to content

Commit aa453e9

Browse files
committed
Print a pre-auto-shutdown shutdown warning
1 parent dd59c8c commit aa453e9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,17 @@ function manageBackgroundServices(
137137
shutdownTimer = undefined;
138138
}
139139

140+
// We do a two-step timer here: 1 minute then a logged warning, then 9 more minutes
141+
// until an automatic server shutdown:
140142
shutdownTimer = setTimeout(() => {
141-
if (activeSessions === 0) {
143+
if (activeSessions !== 0) return;
144+
console.log('Server is inactive, preparing for auto-shutdown...');
145+
146+
shutdownTimer = setTimeout(() => {
147+
if (activeSessions !== 0) return;
142148
shutdown(99, '10 minutes inactive');
143-
}
144-
}, 1000 * 60 * 10).unref();
149+
}, 1000 * 60 * 9).unref();
150+
}, 1000 * 60 * 1).unref();
145151
}
146152
});
147153
}

0 commit comments

Comments
 (0)