@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.rip +20 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/server",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Pure Rip application server — multi-worker, hot reload, HTTPS, mDNS",
5
5
  "type": "module",
6
6
  "main": "server.rip",
package/server.rip CHANGED
@@ -523,15 +523,26 @@ class Manager
523
523
  tracked
524
524
 
525
525
  monitor: (w) ->
526
- await w.process.exited # Wait for process to exit
527
- return if @shuttingDown
528
- return if @retiringIds.has(w.id)
529
- w.restartCount++
530
- w.backoffMs = Math.min(w.backoffMs * 2, 30000)
531
- return if w.restartCount > 10
532
- await new Promise (r) -> setTimeout(r, w.backoffMs)
533
- idx = @workers.findIndex((x) -> x.id is w.id)
534
- @workers[idx] = @spawnWorker!() if idx >= 0
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()