@rip-lang/server 0.5.5 → 0.5.7
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/server.rip +20 -9
package/package.json
CHANGED
package/server.rip
CHANGED
|
@@ -523,15 +523,26 @@ class Manager
|
|
|
523
523
|
tracked
|
|
524
524
|
|
|
525
525
|
monitor: (w) ->
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
526
|
+
# Watch for process exit in background (don't block)
|
|
527
|
+
w.process.exited.then =>
|
|
528
|
+
return if @shuttingDown
|
|
529
|
+
return if @retiringIds.has(w.id)
|
|
530
|
+
|
|
531
|
+
# Notify server to remove dead worker's socket entry
|
|
532
|
+
try
|
|
533
|
+
ctl = getControlSocketPath(@flags.socketPrefix)
|
|
534
|
+
body = JSON.stringify({ op: 'quit', workerId: w.id })
|
|
535
|
+
fetch('http://localhost/worker', { method: 'POST', body, headers: { 'content-type': 'application/json' }, unix: ctl })
|
|
536
|
+
catch
|
|
537
|
+
null
|
|
538
|
+
|
|
539
|
+
w.restartCount++
|
|
540
|
+
w.backoffMs = Math.min(w.backoffMs * 2, 30000)
|
|
541
|
+
return if w.restartCount > 10
|
|
542
|
+
setTimeout =>
|
|
543
|
+
idx = @workers.findIndex((x) -> x.id is w.id)
|
|
544
|
+
@workers[idx] = @spawnWorker(@currentVersion) if idx >= 0
|
|
545
|
+
, w.backoffMs
|
|
535
546
|
|
|
536
547
|
waitWorkerReady: (socketPath, timeoutMs = 5000) ->
|
|
537
548
|
start = Date.now()
|