This commit is contained in:
Sefinek committed 2025-02-01 20:29:35 +01:00
1 parent d5921f19e7
commit 5320952ccb
8 files changed
+47 -49

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
const { AUTO_UPDATE_SCHEDULE } = require('../config.js').MAIN;
const simpleGit = require('simple-git');
const { CronJob } = require('cron');
const restartApp = require('./reloadApp.js');
const log = require('../utils/log.js');
const git = simpleGit();
const pull = async () => {
log(0, '$ git pull');
const { summary } = await git.pull();
log(0, `Changes: ${summary.changes}; Deletions: ${summary.insertions}; Insertions: ${summary.insertions};`);
};
const pullAndRestart = async () => {
try {
await pull();
await restartApp();
} catch (err) {
log(2, err.message);
}
};
// https://crontab.guru
new CronJob(AUTO_UPDATE_SCHEDULE || '0 18 * * *', pullAndRestart, null, true, 'UTC'); // At 18:00
module.exports = { pull };