fix: don't crash process on error in cronjobs

catch error to continue in actor.prune
This commit is contained in:
Barış Soner Uşaklı
2024-06-10 19:24:06 -04:00
parent bad094e888
commit 89465ec604
2 changed files with 21 additions and 4 deletions

View File

@@ -279,8 +279,12 @@ Actors.prune = async () => {
const count = counts[idx];
if (count < 1) {
try {
await user.deleteAccount(uid);
deletionCount += 1;
} catch (err) {
winston.error(err.stack);
}
} else {
reassertionSet.add(uid);
}

View File

@@ -44,8 +44,21 @@ ActivityPub.actors = require('./actors');
ActivityPub.startJobs = () => {
// winston.verbose('[activitypub/jobs] Registering jobs.');
new CronJob('0 0 * * *', ActivityPub.notes.prune, null, true, null, null, false); // change last argument to true for debugging
new CronJob('0 1 * * *', ActivityPub.actors.prune, null, true, null, null, false); // change last argument to true for debugging
new CronJob('0 0 * * *', async () => {
try {
await ActivityPub.notes.prune();
} catch (err) {
winston.error(err.stack);
}
}, null, true, null, null, false); // change last argument to true for debugging
new CronJob('0 1 * * *', async () => {
try {
await ActivityPub.actors.prune();
} catch (err) {
winston.error(err.stack);
}
},, null, true, null, null, false); // change last argument to true for debugging
};
ActivityPub.resolveId = async (uid, id) => {