@rip-lang/server 1.3.19 → 1.3.20
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 +2 -2
- package/server.rip +32 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rip-lang/server",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.20",
|
|
4
4
|
"description": "Pure Rip web framework and application server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "api.rip",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"author": "Steve Shreeve <steve.shreeve@gmail.com>",
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"rip-lang": ">=3.13.
|
|
48
|
+
"rip-lang": ">=3.13.36"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"api.rip",
|
package/server.rip
CHANGED
|
@@ -362,6 +362,13 @@ runSetup = ->
|
|
|
362
362
|
fn = mod?.setup or mod?.default
|
|
363
363
|
if typeof fn is 'function'
|
|
364
364
|
await fn()
|
|
365
|
+
# Signal the Manager that setup is complete
|
|
366
|
+
process.stdout.write '__setup_done__\n'
|
|
367
|
+
# If teardown exported, stay alive until Manager sends SIGTERM
|
|
368
|
+
if typeof mod?.teardown is 'function'
|
|
369
|
+
await new Promise (resolve) ->
|
|
370
|
+
process.once 'SIGTERM', ->
|
|
371
|
+
Promise.resolve(mod.teardown()).finally(resolve)
|
|
365
372
|
catch e
|
|
366
373
|
console.error "rip-server: setup failed:", e
|
|
367
374
|
process.exit(1)
|
|
@@ -500,6 +507,7 @@ class Manager
|
|
|
500
507
|
@retiringIds = new Set()
|
|
501
508
|
@currentVersion = 1
|
|
502
509
|
@server = null
|
|
510
|
+
@setupProc = null
|
|
503
511
|
@appWatchers = new Map()
|
|
504
512
|
|
|
505
513
|
process.on 'SIGTERM', => @shutdown!
|
|
@@ -515,15 +523,32 @@ class Manager
|
|
|
515
523
|
RIP_SETUP_MODE: '1'
|
|
516
524
|
RIP_SETUP_FILE: setupFile
|
|
517
525
|
proc = Bun.spawn ['rip', import.meta.path],
|
|
518
|
-
stdout: '
|
|
526
|
+
stdout: 'pipe'
|
|
519
527
|
stderr: 'inherit'
|
|
520
528
|
stdin: 'ignore'
|
|
521
529
|
cwd: process.cwd()
|
|
522
530
|
env: setupEnv
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
531
|
+
|
|
532
|
+
# Stream stdout to our stdout, watching for the __setup_done__ signal
|
|
533
|
+
setupDone = new Promise (resolve, reject) ->
|
|
534
|
+
buf = ''
|
|
535
|
+
reader = proc.stdout.getReader()
|
|
536
|
+
dec = new TextDecoder()
|
|
537
|
+
readLoop = ->
|
|
538
|
+
{ done, value } = await reader.read()
|
|
539
|
+
if done
|
|
540
|
+
code = await proc.exited
|
|
541
|
+
if code isnt 0 then reject new Error "setup exited #{code}" else resolve()
|
|
542
|
+
return
|
|
543
|
+
buf += dec.decode(value)
|
|
544
|
+
lines = buf.split('\n')
|
|
545
|
+
buf = lines.pop()
|
|
546
|
+
for line in lines
|
|
547
|
+
if line is '__setup_done__' then resolve() else process.stdout.write line + '\n'
|
|
548
|
+
readLoop()
|
|
549
|
+
readLoop()
|
|
550
|
+
await setupDone
|
|
551
|
+
@setupProc = proc
|
|
527
552
|
|
|
528
553
|
@workers = []
|
|
529
554
|
for i in [0...@flags.workers]
|
|
@@ -711,6 +736,8 @@ class Manager
|
|
|
711
736
|
return if @shuttingDown
|
|
712
737
|
@shuttingDown = true
|
|
713
738
|
@stop!
|
|
739
|
+
# Signal the setup process to run teardown (kills rip-db if we launched it)
|
|
740
|
+
@setupProc?.kill('SIGTERM')
|
|
714
741
|
process.exit(0)
|
|
715
742
|
|
|
716
743
|
getEntryMtime: ->
|