@rip-lang/server 1.3.20 → 1.3.22

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 +2 -2
  2. package/server.rip +12 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/server",
3
- "version": "1.3.20",
3
+ "version": "1.3.22",
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.36"
48
+ "rip-lang": ">=3.13.38"
49
49
  },
50
50
  "files": [
51
51
  "api.rip",
package/server.rip CHANGED
@@ -362,13 +362,9 @@ 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
+ # Send the DB URL to the Manager via IPC (null if rip-db was already running)
366
+ url = if typeof mod?.dbUrl is 'function' then mod.dbUrl() else null
367
+ process.send({ dbUrl: url }) if process.send
372
368
  catch e
373
369
  console.error "rip-server: setup failed:", e
374
370
  process.exit(1)
@@ -507,7 +503,7 @@ class Manager
507
503
  @retiringIds = new Set()
508
504
  @currentVersion = 1
509
505
  @server = null
510
- @setupProc = null
506
+ @dbUrl = null
511
507
  @appWatchers = new Map()
512
508
 
513
509
  process.on 'SIGTERM', => @shutdown!
@@ -523,32 +519,17 @@ class Manager
523
519
  RIP_SETUP_MODE: '1'
524
520
  RIP_SETUP_FILE: setupFile
525
521
  proc = Bun.spawn ['rip', import.meta.path],
526
- stdout: 'pipe'
522
+ stdout: 'inherit'
527
523
  stderr: 'inherit'
528
524
  stdin: 'ignore'
529
525
  cwd: process.cwd()
530
526
  env: setupEnv
527
+ ipc: (msg) => @dbUrl = msg.dbUrl if msg?.dbUrl
531
528
 
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
529
+ code = await proc.exited
530
+ if code isnt 0
531
+ console.error "rip-server: setup exited with code #{code}"
532
+ process.exit(1)
552
533
 
553
534
  @workers = []
554
535
  for i in [0...@flags.workers]
@@ -736,8 +717,8 @@ class Manager
736
717
  return if @shuttingDown
737
718
  @shuttingDown = true
738
719
  @stop!
739
- # Signal the setup process to run teardown (kills rip-db if we launched it)
740
- @setupProc?.kill('SIGTERM')
720
+ # Shutdown rip-db if we launched it — HTTP call, clean WAL checkpoint
721
+ try fetch!(@dbUrl + '/shutdown', { method: 'POST' }) if @dbUrl catch then null
741
722
  process.exit(0)
742
723
 
743
724
  getEntryMtime: ->