Fix crash when cron seed file is missing
This commit is contained in:
@@ -140,7 +140,7 @@ async function runStartupTasks() {
|
||||
// we used to run tasks in parallel but simultaneous nginx reloads was causing issues
|
||||
for (let i = 0; i < tasks.length; i++) {
|
||||
const [error] = await safe(tasks[i]());
|
||||
if (error) debug(`Startup task at index ${i} failed: ${error.message}`);
|
||||
if (error) debug(`Startup task at index ${i} failed: ${error.message} ${error.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
src/cron.js
13
src/cron.js
@@ -66,15 +66,14 @@ function getCronSeed() {
|
||||
let hour = null;
|
||||
let minute = null;
|
||||
|
||||
let tmp = safe.fs.readFileSync(paths.CRON_SEED_FILE, 'utf8');
|
||||
if (tmp) tmp = tmp.split(':');
|
||||
|
||||
if (tmp.length === 2) {
|
||||
hour = parseInt(tmp[0]);
|
||||
minute = parseInt(tmp[1]);
|
||||
const seedData = safe.fs.readFileSync(paths.CRON_SEED_FILE, 'utf8') || '';
|
||||
const parts = seedData.split(':');
|
||||
if (parts.length === 2) {
|
||||
hour = parseInt(parts[0]) || null;
|
||||
minute = parseInt(parts[1]) || null;
|
||||
}
|
||||
|
||||
if ((isNaN(hour) || hour < 0 || hour > 23) || (isNaN(minute) || minute < 0 || minute > 60)) {
|
||||
if ((hour == null || hour < 0 || hour > 23) || (minute == null || minute < 0 || minute > 60)) {
|
||||
hour = Math.floor(24 * Math.random());
|
||||
minute = Math.floor(60 * Math.random());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user