git-watchtower 1.10.19 → 1.10.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server/process.js +9 -5
package/package.json
CHANGED
package/src/server/process.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const { spawn } = require('child_process');
|
|
7
7
|
const { ServerError } = require('../utils/errors');
|
|
8
|
+
const { Mutex } = require('../utils/async');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @typedef {Object} ServerProcessState
|
|
@@ -90,6 +91,7 @@ class ProcessManager {
|
|
|
90
91
|
this.crashed = false;
|
|
91
92
|
this.logs = [];
|
|
92
93
|
this.command = '';
|
|
94
|
+
this._restartMutex = new Mutex();
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/**
|
|
@@ -283,13 +285,15 @@ class ProcessManager {
|
|
|
283
285
|
* @returns {Promise<{success: boolean, error?: Error, pid?: number}>}
|
|
284
286
|
*/
|
|
285
287
|
async restart() {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
+
return this._restartMutex.withLock(async () => {
|
|
289
|
+
const command = this.command;
|
|
290
|
+
this.stop();
|
|
288
291
|
|
|
289
|
-
|
|
290
|
-
|
|
292
|
+
// Wait before restarting
|
|
293
|
+
await new Promise((resolve) => setTimeout(resolve, RESTART_DELAY));
|
|
291
294
|
|
|
292
|
-
|
|
295
|
+
return this.start(command);
|
|
296
|
+
});
|
|
293
297
|
}
|
|
294
298
|
|
|
295
299
|
/**
|