@onereach/billing-shared 30.7.9-beta.12294.0 → 30.7.9-beta.12302.0
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/scripts/dev-single.mjs +4 -22
package/package.json
CHANGED
package/scripts/dev-single.mjs
CHANGED
|
@@ -9,14 +9,7 @@ const __dirname = dirname(__filename);
|
|
|
9
9
|
const lockDir = '/tmp/shared-esm-build.lock';
|
|
10
10
|
const pidFile = resolve(lockDir, 'pid');
|
|
11
11
|
let ownsLock = false;
|
|
12
|
-
|
|
13
|
-
let stopRequested = false;
|
|
14
|
-
|
|
15
|
-
const requestStop = () => {
|
|
16
|
-
stopRequested = true;
|
|
17
|
-
};
|
|
18
|
-
process.on('SIGINT', requestStop);
|
|
19
|
-
process.on('SIGTERM', requestStop);
|
|
12
|
+
const startupDeadline = Date.now() + 1000;
|
|
20
13
|
|
|
21
14
|
const isAlive = (pid) => { try { process.kill(pid, 0);return true; } catch { return false; } };
|
|
22
15
|
const reclaimLock = () => {
|
|
@@ -33,8 +26,6 @@ const reclaimLock = () => {
|
|
|
33
26
|
});
|
|
34
27
|
};
|
|
35
28
|
while (!ownsLock) {
|
|
36
|
-
if (stopRequested) process.exit(0);
|
|
37
|
-
|
|
38
29
|
try {
|
|
39
30
|
mkdirSync(lockDir);
|
|
40
31
|
ownsLock = true;
|
|
@@ -45,29 +36,22 @@ while (!ownsLock) {
|
|
|
45
36
|
// eslint-disable-next-line no-empty
|
|
46
37
|
try { oldPid = Number(readFileSync(pidFile, 'utf8').trim()); } catch {}
|
|
47
38
|
if (!Number.isNaN(oldPid) && isAlive(oldPid)) {
|
|
48
|
-
emptyLockObservedAt = undefined;
|
|
49
39
|
// eslint-disable-next-line no-console
|
|
50
|
-
console.log(`shared already running (pid=${oldPid})
|
|
51
|
-
|
|
52
|
-
await new Promise(resolve => { setTimeout(resolve, 250); });
|
|
53
|
-
}
|
|
54
|
-
continue;
|
|
40
|
+
console.log(`shared already running (pid=${oldPid})`);
|
|
41
|
+
process.exit(0);
|
|
55
42
|
}
|
|
56
43
|
|
|
57
44
|
if (Number.isNaN(oldPid)) {
|
|
58
|
-
|
|
59
|
-
if (Date.now() - emptyLockObservedAt < 1000) {
|
|
45
|
+
if (Date.now() < startupDeadline) {
|
|
60
46
|
await new Promise(resolve => { setTimeout(resolve, 25); });
|
|
61
47
|
continue;
|
|
62
48
|
}
|
|
63
49
|
|
|
64
50
|
reclaimLock();
|
|
65
|
-
emptyLockObservedAt = undefined;
|
|
66
51
|
continue;
|
|
67
52
|
}
|
|
68
53
|
|
|
69
54
|
reclaimLock();
|
|
70
|
-
emptyLockObservedAt = undefined;
|
|
71
55
|
}
|
|
72
56
|
}
|
|
73
57
|
|
|
@@ -93,8 +77,6 @@ const shutdown = (signal) => {
|
|
|
93
77
|
shuttingDown = true;
|
|
94
78
|
child.kill(signal);
|
|
95
79
|
};
|
|
96
|
-
process.removeListener('SIGINT', requestStop);
|
|
97
|
-
process.removeListener('SIGTERM', requestStop);
|
|
98
80
|
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
99
81
|
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
100
82
|
|