Fix autosave

pull/224/head
Krisztian Korosi 2022-12-06 07:38:28 +01:00
parent 8d9e9a73a3
commit dd4546f250
2 changed files with 8 additions and 2 deletions

9
app.js
View File

@ -271,8 +271,13 @@ server.listen(app.get('port'), app.get('host'), function() {
// If --autosave is used then we will also save whatever is in the db automatically without having to mention it explictly
// we do this by watching log file and setting a on change hook to it
if (process.argv.includes("--autosave") || process.env.ENABLE_AUTOSAVE) {
crontab.autosave_crontab(()=>{});
fs.watchFile(crontab.crontab_db_file, () => {
crontab.autosave_crontab(()=>{
console.log("Attempted to autosave crontab");
});
fs.watchFile(crontab.crontab_db_file, (curr, prev) => {
if (curr.mtime === prev.mtime) {
return;
}
crontab.autosave_crontab(()=>{
console.log("Attempted to autosave crontab");
});

View File

@ -10,6 +10,7 @@ exports.env_file = path.join(exports.db_folder, 'env.db');
exports.crontab_db_file = path.join(exports.db_folder, 'crontab.db');
var db = new Datastore({ filename: exports.crontab_db_file});
db.persistence.setAutocompactionInterval(30000);
var cronPath = "/tmp";
if(process.env.CRON_PATH !== undefined) {
console.log(`Path to crond files set using env variables ${process.env.CRON_PATH}`);