about summary refs log tree commit diff stats
path: root/src/sleep.ts
diff options
context:
space:
mode:
authorAlan Pearce2024-04-10 11:33:01 +0200
committerAlan Pearce2024-04-10 11:33:01 +0200
commit8beec515146fc8cc323d9de722a405372801e1df (patch)
tree9af1125471e312f4d3ae0e1026fd2018d7edabc8 /src/sleep.ts
parent8de5eac6f52beba26d3ce6b5406dcf4ac35da641 (diff)
downloadwebsite-8beec515146fc8cc323d9de722a405372801e1df.tar.lz
website-8beec515146fc8cc323d9de722a405372801e1df.tar.zst
website-8beec515146fc8cc323d9de722a405372801e1df.zip
fly: stop running in secondary regions if no meaningful requests
Diffstat (limited to 'src/sleep.ts')
-rw-r--r--src/sleep.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sleep.ts b/src/sleep.ts
new file mode 100644
index 0000000..94d7547
--- /dev/null
+++ b/src/sleep.ts
@@ -0,0 +1,8 @@
+let sleepTimeout: Timer;
+
+export function keepAwake() {
+  if (sleepTimeout) clearTimeout(sleepTimeout);
+  sleepTimeout = setTimeout(function () {
+    process.exit(0);
+  }, 60_000);
+}