Fix autosave
parent
8d9e9a73a3
commit
dd4546f250
9
app.js
9
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");
|
||||
});
|
||||
|
|
|
@ -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}`);
|
||||
|
|
Loading…
Reference in New Issue