summaryrefslogtreecommitdiff
path: root/src/daemons
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemons')
-rw-r--r--src/daemons/janitor.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/daemons/janitor.ts b/src/daemons/janitor.ts
new file mode 100644
index 0000000000..462ebf915c
--- /dev/null
+++ b/src/daemons/janitor.ts
@@ -0,0 +1,18 @@
+const interval = 30 * 60 * 1000;
+import { AttestationChallenges } from '../models';
+import { LessThan } from 'typeorm';
+
+/**
+ * Clean up database occasionally
+ */
+export default function() {
+ async function tick() {
+ await AttestationChallenges.delete({
+ createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000))
+ });
+ }
+
+ tick();
+
+ setInterval(tick, interval);
+}