@lark-apaas/fullstack-cli 1.1.41 → 1.1.43-alpha.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.41",
3
+ "version": "1.1.43-alpha.0",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@lark-apaas/http-client": "^0.1.2",
34
+ "@lark-apaas/http-client": "^0.1.5",
35
35
  "@lydell/node-pty": "1.1.0",
36
36
  "@vercel/nft": "^0.30.3",
37
37
  "commander": "^13.0.0",
@@ -31,9 +31,11 @@ loadEnv();
31
31
 
32
32
  // ── Configuration ─────────────────────────────────────────────────────────────
33
33
  const LOG_DIR = process.env.LOG_DIR || 'logs';
34
- const MAX_RESTART_COUNT = parseInt(process.env.MAX_RESTART_COUNT, 10) || 10;
34
+ const MAX_RESTART_COUNT = process.env.MAX_RESTART_COUNT != null && process.env.MAX_RESTART_COUNT !== ''
35
+ ? parseInt(process.env.MAX_RESTART_COUNT, 10)
36
+ : Infinity;
35
37
  const RESTART_DELAY = parseInt(process.env.RESTART_DELAY, 10) || 2;
36
- const MAX_DELAY = 60;
38
+ const MAX_DELAY = 8;
37
39
  const SERVER_PORT = process.env.SERVER_PORT || '3000';
38
40
  const CLIENT_DEV_PORT = process.env.CLIENT_DEV_PORT || '8080';
39
41
 
@@ -125,6 +127,7 @@ function startProcess({ name, command, args, cleanupPort }) {
125
127
  entry.pid = child.pid;
126
128
  entry.child = child;
127
129
 
130
+ const startTime = Date.now();
128
131
  logEvent('INFO', name, `Process started (PGID: ${child.pid}): ${command} ${args.join(' ')}`);
129
132
 
130
133
  // Pipe stdout and stderr through readline for timestamped logging
@@ -168,13 +171,19 @@ function startProcess({ name, command, args, cleanupPort }) {
168
171
 
169
172
  if (stopping) break;
170
173
 
171
- restartCount++;
174
+ const runDuration = (Date.now() - startTime) / 1000;
175
+ if (runDuration >= 60) {
176
+ restartCount = 0;
177
+ logEvent('INFO', name, `Ran for ${Math.round(runDuration)}s, resetting restart counter`);
178
+ } else {
179
+ restartCount++;
180
+ }
172
181
  if (restartCount >= MAX_RESTART_COUNT) {
173
182
  logEvent('ERROR', name, `Max restart count (${MAX_RESTART_COUNT}) reached, giving up`);
174
183
  break;
175
184
  }
176
185
 
177
- const delay = Math.min(RESTART_DELAY * (1 << (restartCount - 1)), MAX_DELAY);
186
+ const delay = Math.min(RESTART_DELAY * (1 << Math.max(0, restartCount - 1)), MAX_DELAY);
178
187
  logEvent('WARN', name, `Process exited with code ${exitCode}, restarting (${restartCount}/${MAX_RESTART_COUNT}) in ${delay}s...`);
179
188
  await sleep(delay * 1000);
180
189
  }