Browse Source

properly catch error running cron job

pull/1349/head
Bernd Storath 9 months ago
parent
commit
f893f2e4d2
No known key found for this signature in database GPG Key ID: D6C85685A555540F
  1. 11
      src/server/utils/WireGuard.ts

11
src/server/utils/WireGuard.ts

@ -43,7 +43,6 @@ class WireGuard {
} }
debug('Loading configuration...'); debug('Loading configuration...');
// TODO: Better way to invalidate cache
this.#configCache = null; this.#configCache = null;
try { try {
const config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8'); const config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8');
@ -575,13 +574,13 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
} }
const inst = new WireGuard(); const inst = new WireGuard();
inst.getConfig().catch((err) => {
console.error(err);
process.exit(1);
});
// This also has to also start the WireGuard Server
async function cronJobEveryMinute() { async function cronJobEveryMinute() {
await inst.cronJobEveryMinute(); await inst.cronJobEveryMinute().catch((err) => {
debug('Running Cron Job failed.');
console.error(err);
});
setTimeout(cronJobEveryMinute, 60 * 1000); setTimeout(cronJobEveryMinute, 60 * 1000);
} }
cronJobEveryMinute(); cronJobEveryMinute();

Loading…
Cancel
Save