diff --git a/app.js b/app.js index 1bc4f4e..fdd4749 100755 --- a/app.js +++ b/app.js @@ -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"); }); diff --git a/crontab.js b/crontab.js index 576b79b..c4de25b 100644 --- a/crontab.js +++ b/crontab.js @@ -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}`);