Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 0977836

Browse files
committed
Add delay to start scheduler at :00 - fixes NativePHP/laravel#72
1 parent bdf5edd commit 0977836

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

dist/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,14 @@ class NativePHP {
109109
if (((_a = nativePHPConfig === null || nativePHPConfig === void 0 ? void 0 : nativePHPConfig.updater) === null || _a === void 0 ? void 0 : _a.enabled) === true) {
110110
electron_updater_1.autoUpdater.checkForUpdatesAndNotify();
111111
}
112-
schedulerInterval = setInterval(() => {
113-
console.log("Running scheduler...");
114-
(0, server_1.runScheduler)(apiPort.port);
115-
}, 60 * 1000);
112+
let now = new Date();
113+
let delay = (60 - now.getSeconds()) * 1000 + (1000 - now.getMilliseconds());
114+
setTimeout(() => {
115+
schedulerInterval = setInterval(() => {
116+
console.log("Running scheduler...");
117+
(0, server_1.runScheduler)(apiPort.port);
118+
}, 60 * 1000);
119+
}, delay);
116120
app.on('activate', function (event, hasVisibleWindows) {
117121
if (!hasVisibleWindows) {
118122
(0, utils_2.notifyLaravel)('booted');

src/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ class NativePHP {
127127
autoUpdater.checkForUpdatesAndNotify()
128128
}
129129

130-
schedulerInterval = setInterval(() => {
131-
console.log("Running scheduler...")
132-
runScheduler(apiPort.port);
133-
}, 60 * 1000);
130+
let now = new Date();
131+
let delay = (60 - now.getSeconds()) * 1000 + (1000 - now.getMilliseconds());
132+
133+
setTimeout(() => {
134+
schedulerInterval = setInterval(() => {
135+
console.log("Running scheduler...")
136+
runScheduler(apiPort.port);
137+
}, 60 * 1000);
138+
}, delay);
134139

135140
app.on('activate', function (event, hasVisibleWindows) {
136141
// On macOS it's common to re-create a window in the app when the

0 commit comments

Comments
 (0)