depository-deploy 1.0.30 → 1.0.40

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.
@@ -317,6 +317,58 @@ kill_port_holder "$API_PORT"
317
317
  kill_port_holder "$AUTH_PORT"
318
318
  kill_port_holder "$GATHERER_PORT"
319
319
 
320
+ # ---- Map service name → executable path (for direct-run error capture) ----
321
+ get_svc_exe() {
322
+ case "$1" in
323
+ depository-auth) echo "$INSTALL_DIR/auth/DEPOSITORY.API.OATH" ;;
324
+ depository-api) echo "$INSTALL_DIR/api/DEPOSITORY.API.REST" ;;
325
+ depository-worker) echo "$INSTALL_DIR/worker/DEPOSITORY.CORE.WORKER" ;;
326
+ depository-gatherer) echo "$INSTALL_DIR/gatherer/DEPOSITORY.CORE.GATHERER" ;;
327
+ depository-digestor) echo "$INSTALL_DIR/digestor/DEPOSITORY.CORE.DIGESTOR" ;;
328
+ esac
329
+ }
330
+
331
+ # Capture and print detailed startup error for a failed service
332
+ capture_svc_error() {
333
+ local svc="$1"
334
+ warn " --- journalctl output (last 50 lines) ---"
335
+ journalctl -u "$svc" -n 50 --no-pager 2>/dev/null | while IFS= read -r line; do
336
+ warn " $line"
337
+ done
338
+
339
+ # Also try running the executable directly for 5 seconds to surface startup exceptions
340
+ local svc_exe
341
+ svc_exe="$(get_svc_exe "$svc")"
342
+ if [ -n "$svc_exe" ] && [ -f "$svc_exe" ]; then
343
+ warn " --- Running exe directly to capture startup error (5 s) ---"
344
+ local tmp_out="/tmp/${svc}-startup-$$.log"
345
+ local svc_dir
346
+ svc_dir="$(dirname "$svc_exe")"
347
+ # Run as depository user if available so appsettings.json is readable
348
+ if id -u depository &>/dev/null; then
349
+ timeout 5 sudo -u depository "$svc_exe" 2>&1 | head -60 > "$tmp_out" || true
350
+ else
351
+ timeout 5 "$svc_exe" 2>&1 | head -60 > "$tmp_out" || true
352
+ fi
353
+ if [ -s "$tmp_out" ]; then
354
+ while IFS= read -r line; do
355
+ warn " $line"
356
+ done < "$tmp_out"
357
+ else
358
+ warn " (no output captured from direct run)"
359
+ fi
360
+ rm -f "$tmp_out"
361
+ # Also show startup-error.log written by the .NET app itself
362
+ local err_log="$svc_dir/startup-error.log"
363
+ if [ -f "$err_log" ]; then
364
+ warn " --- $err_log ---"
365
+ while IFS= read -r line; do
366
+ warn " $line"
367
+ done < "$err_log"
368
+ fi
369
+ fi
370
+ }
371
+
320
372
  # ---- Enable and start services ----
321
373
  info "Enabling and starting services..."
322
374
  systemctl daemon-reload
@@ -331,18 +383,12 @@ for svc in $SERVICES; do
331
383
  echo -e " ${GREEN}[OK]${NC} Started: $svc"
332
384
  else
333
385
  warn " FAILED to start: $svc (did not reach active state)"
334
- warn " Run: journalctl -u $svc -n 30 --no-pager"
335
- journalctl -u "$svc" -n 8 --no-pager 2>/dev/null | grep -iE 'error|fail|exception|unhandled|crit' | head -5 | while read -r line; do
336
- warn " $line"
337
- done
386
+ capture_svc_error "$svc"
338
387
  START_FAILED="$START_FAILED $svc"
339
388
  fi
340
389
  else
341
390
  warn " FAILED to start: $svc"
342
- warn " Run: journalctl -u $svc -n 30 --no-pager"
343
- journalctl -u "$svc" -n 8 --no-pager 2>/dev/null | grep -iE 'error|fail|exception|unhandled|crit' | head -5 | while read -r line; do
344
- warn " $line"
345
- done
391
+ capture_svc_error "$svc"
346
392
  START_FAILED="$START_FAILED $svc"
347
393
  fi
348
394
  done
@@ -262,22 +262,13 @@ $svcDefs = @(
262
262
  )
263
263
 
264
264
  foreach ($def in $svcDefs) {
265
- # Create a wrapper batch that sets the working directory (so appsettings.json is found)
266
- # and optionally sets environment variables (e.g. ASPNETCORE_URLS for port binding).
267
- $exeDir = Split-Path -Parent $def.Exe
268
- $wrapperPath = Join-Path $exeDir "start-service.bat"
269
- $batLines = "@echo off"
270
- $batLines += "`r`ncd /d `"$exeDir`""
271
- if ($def.Env -ne "") {
272
- $batLines += "`r`nset $($def.Env)"
273
- }
274
- $batLines += "`r`n`"$($def.Exe)`""
275
- Set-Content -Path $wrapperPath -Value $batLines -Encoding ASCII
276
-
277
- & sc.exe create $def.Name binPath= "`"$wrapperPath`"" start= auto DisplayName= $def.Desc | Out-Null
265
+ # Register the exe directly as the Windows Service binary.
266
+ # UseWindowsService() in each app handles the SCM protocol and sets the content root
267
+ # to the exe's directory so appsettings.json is found automatically.
268
+ & sc.exe create $def.Name binPath= "`"$($def.Exe)`"" start= auto DisplayName= $def.Desc | Out-Null
278
269
  & sc.exe description $def.Name $def.Desc | Out-Null
279
270
 
280
- # Also set environment via registry as a fallback
271
+ # Pass environment variables (e.g. ASPNETCORE_URLS) via the service registry entry
281
272
  if ($def.Env -ne "") {
282
273
  $regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\$($def.Name)"
283
274
  Set-ItemProperty -Path $regPath -Name "Environment" -Value @($def.Env) -Type MultiString -ErrorAction SilentlyContinue
@@ -356,15 +347,22 @@ foreach ($def in $svcDefs) {
356
347
  -RedirectStandardOutput "$env:TEMP\$($def.Name)-stdout.txt" `
357
348
  -RedirectStandardError "$env:TEMP\$($def.Name)-stderr.txt" `
358
349
  -NoNewWindow -PassThru -ErrorAction SilentlyContinue
359
- Start-Sleep -Seconds 3
350
+ Start-Sleep -Seconds 5
360
351
  if (-not $proc.HasExited) { $proc.Kill() }
361
352
  $stdout = Get-Content "$env:TEMP\$($def.Name)-stdout.txt" -ErrorAction SilentlyContinue
362
353
  $stderr = Get-Content "$env:TEMP\$($def.Name)-stderr.txt" -ErrorAction SilentlyContinue
363
- $combined = @($stdout; $stderr) | Where-Object { $_ -match 'error|fail|exception|unhandled|crit' -and $_ }
354
+ $combined = @($stdout; $stderr) | Where-Object { $_ -and $_.Trim() }
364
355
  if ($combined) {
365
- $combined | Select-Object -First 8 | ForEach-Object { Write-Warn " $_" }
356
+ Write-Warn " --- Startup output (stdout + stderr) ---"
357
+ $combined | Select-Object -First 30 | ForEach-Object { Write-Warn " $_" }
366
358
  } else {
367
- Write-Warn " (no error output captured -- check Event Viewer)"
359
+ Write-Warn " (no output captured -- check Event Viewer > Windows Logs > Application)"
360
+ }
361
+ # Also surface startup-error.log written by the .NET app itself
362
+ $errLog = Join-Path $exeDir "startup-error.log"
363
+ if (Test-Path $errLog) {
364
+ Write-Warn " --- $errLog ---"
365
+ Get-Content $errLog -ErrorAction SilentlyContinue | Select-Object -First 50 | ForEach-Object { Write-Warn " $_" }
368
366
  }
369
367
  } catch {
370
368
  Write-Warn " Could not run exe directly: $_"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "depository-deploy",
3
- "version": "1.0.30",
3
+ "version": "1.0.40",
4
4
  "description": "Depository document management system – deployment wizard and installers",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -25,9 +25,9 @@
25
25
  "scripts/publish.mjs"
26
26
  ],
27
27
  "optionalDependencies": {
28
- "depository-deploy-linux": "1.0.30",
29
- "depository-deploy-macos": "1.0.30",
30
- "depository-deploy-windows": "1.0.30"
28
+ "depository-deploy-linux": "1.0.40",
29
+ "depository-deploy-macos": "1.0.40",
30
+ "depository-deploy-windows": "1.0.40"
31
31
  },
32
32
  "scripts": {
33
33
  "start": "node wizard-server.mjs"