@rip-lang/server 1.3.22 → 1.3.24

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 +11 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/server",
3
- "version": "1.3.22",
3
+ "version": "1.3.24",
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.38"
48
+ "rip-lang": ">=3.13.40"
49
49
  },
50
50
  "files": [
51
51
  "api.rip",
package/server.rip CHANGED
@@ -125,7 +125,7 @@ logAccessHuman = (app, req, res, totalSeconds, workerSeconds) ->
125
125
  contentType = (res.headers.get('content-type') or '').split(';')[0] or ''
126
126
  sub = if contentType.includes('/') then contentType.split('/')[1] else contentType
127
127
  type = (typeAbbrev[sub] or sub or '').padEnd(4)
128
- console.log "[#{timestamp} #{timezone} #{dur}] #{status} #{type} #{size} │ #{method} #{path}"
128
+ console.log "#{timestamp} #{timezone} #{dur} #{status} #{type} #{size} │ #{method} #{path}"
129
129
 
130
130
  INTERNAL_HEADERS = new Set(['rip-worker-busy', 'rip-worker-id', 'rip-no-log'])
131
131
 
@@ -362,9 +362,6 @@ runSetup = ->
362
362
  fn = mod?.setup or mod?.default
363
363
  if typeof fn is 'function'
364
364
  await fn()
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
368
365
  catch e
369
366
  console.error "rip-server: setup failed:", e
370
367
  process.exit(1)
@@ -515,6 +512,16 @@ class Manager
515
512
  # Run one-time setup if setup.rip exists next to the entry file
516
513
  setupFile = join(dirname(@flags.appEntry), 'setup.rip')
517
514
  if existsSync(setupFile)
515
+ # Check reachability before setup — determines if WE will start the DB
516
+ dbUrl = process.env.DB_URL or 'http://localhost:4213'
517
+ dbAlreadyRunning = do ->
518
+ try
519
+ await fetch(dbUrl + '/health')
520
+ true
521
+ catch
522
+ false
523
+ @dbUrl = dbUrl unless dbAlreadyRunning
524
+
518
525
  setupEnv = Object.assign {}, process.env,
519
526
  RIP_SETUP_MODE: '1'
520
527
  RIP_SETUP_FILE: setupFile
@@ -524,7 +531,6 @@ class Manager
524
531
  stdin: 'ignore'
525
532
  cwd: process.cwd()
526
533
  env: setupEnv
527
- ipc: (msg) => @dbUrl = msg.dbUrl if msg?.dbUrl
528
534
 
529
535
  code = await proc.exited
530
536
  if code isnt 0
@@ -717,7 +723,6 @@ class Manager
717
723
  return if @shuttingDown
718
724
  @shuttingDown = true
719
725
  @stop!
720
- # Shutdown rip-db if we launched it — HTTP call, clean WAL checkpoint
721
726
  try fetch!(@dbUrl + '/shutdown', { method: 'POST' }) if @dbUrl catch then null
722
727
  process.exit(0)
723
728