@danhachuel/jobfinder 0.1.15 → 0.1.16
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/CHANGELOG.md +22 -0
- package/README.md +66 -0
- package/ecosystem.config.cjs +36 -0
- package/package.json +9 -2
- package/scripts/cli.mjs +151 -1
- package/scripts/manual-tests/fase4-npx-start.mjs +35 -18
- package/scripts/manual-tests/fase5-daemon.mjs +168 -0
- package/scripts/start-windows.cmd +9 -0
- package/scripts/start-windows.ps1 +108 -0
- package/src/ui/dist/assets/{index-DtY7qbQR.js → index-BIl6BJNG.js} +1 -1
- package/src/ui/dist/index.html +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Inicia o JobFinder em background (modo daemon) no Windows.
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
Alternativa "a prova de balas" ao `npx` rodando direto no MobaXterm /
|
|
7
|
+
PowerShell. O terminal interativo (e o wrapper do npx) pode matar o
|
|
8
|
+
processo filho a qualquer momento; aqui o servidor sobe DETACHED, com o
|
|
9
|
+
log em disco, e sobrevive ao fechamento do terminal.
|
|
10
|
+
|
|
11
|
+
Uso:
|
|
12
|
+
.\start-windows.ps1 # pacote latest do npm
|
|
13
|
+
.\start-windows.ps1 -Version 0.1.16 # versão fixa
|
|
14
|
+
.\start-windows.ps1 -Local # working copy (desenvolvimento)
|
|
15
|
+
.\start-windows.ps1 -Stop # encerra o daemon
|
|
16
|
+
|
|
17
|
+
.NOTES
|
|
18
|
+
O app grava seu próprio log em %USERPROFILE%\.jobfinder\jobfinder.log —
|
|
19
|
+
por isso o script NÃO redireciona a saída do processo. `Start-Process`
|
|
20
|
+
com redireção (ou `&`) faz o PowerShell esperar handles do processo
|
|
21
|
+
nativo, e um daemon que herdou qualquer handle travaria o script.
|
|
22
|
+
#>
|
|
23
|
+
[CmdletBinding()]
|
|
24
|
+
param(
|
|
25
|
+
[string]$Version = "latest",
|
|
26
|
+
[int]$Port = 4040,
|
|
27
|
+
[switch]$Stop,
|
|
28
|
+
[switch]$Local
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
$ErrorActionPreference = "Stop"
|
|
32
|
+
$pkg = "@danhachuel/jobfinder@$Version"
|
|
33
|
+
|
|
34
|
+
# Resolve o comando: pacote do npm (padrão) ou working copy (-Local).
|
|
35
|
+
if ($Local) {
|
|
36
|
+
$repoRoot = Split-Path -Parent $PSScriptRoot
|
|
37
|
+
$exe = "node"
|
|
38
|
+
$cliArgs = @((Join-Path $repoRoot "scripts\cli.mjs"))
|
|
39
|
+
$label = "working copy ($repoRoot)"
|
|
40
|
+
} else {
|
|
41
|
+
$exe = "npx"
|
|
42
|
+
$cliArgs = @("--yes", $pkg)
|
|
43
|
+
$label = $pkg
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function Test-JobFinderUp {
|
|
47
|
+
param([int]$Port)
|
|
48
|
+
try {
|
|
49
|
+
$response = Invoke-WebRequest -Uri "http://127.0.0.1:$Port/api/health" -TimeoutSec 3 -UseBasicParsing
|
|
50
|
+
return $response.StatusCode -eq 200
|
|
51
|
+
} catch {
|
|
52
|
+
return $false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function Wait-JobFinderUp {
|
|
57
|
+
param([int]$Port, [int]$Seconds = 30)
|
|
58
|
+
for ($i = 0; $i -lt $Seconds; $i++) {
|
|
59
|
+
if (Test-JobFinderUp -Port $Port) { return $true }
|
|
60
|
+
Start-Sleep -Seconds 1
|
|
61
|
+
}
|
|
62
|
+
return $false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Data dir: mesma precedência do CLI (JOBFINDER_HOME > JOBFINDER_DATA_DIR > ~/.jobfinder).
|
|
66
|
+
if ($env:JOBFINDER_HOME) { $dataDir = $env:JOBFINDER_HOME }
|
|
67
|
+
elseif ($env:JOBFINDER_DATA_DIR) { $dataDir = $env:JOBFINDER_DATA_DIR }
|
|
68
|
+
else { $dataDir = Join-Path $env:USERPROFILE ".jobfinder" }
|
|
69
|
+
$logFile = Join-Path $dataDir "jobfinder.log"
|
|
70
|
+
|
|
71
|
+
if ($Stop) {
|
|
72
|
+
Write-Host "Parando o JobFinder ($label)..." -ForegroundColor Cyan
|
|
73
|
+
Start-Process -FilePath $exe -ArgumentList ($cliArgs + @("stop")) -WindowStyle Hidden
|
|
74
|
+
# Confirma que a porta deixou de responder.
|
|
75
|
+
$down = $false
|
|
76
|
+
for ($i = 0; $i -lt 15; $i++) {
|
|
77
|
+
if (-not (Test-JobFinderUp -Port $Port)) { $down = $true; break }
|
|
78
|
+
Start-Sleep -Seconds 1
|
|
79
|
+
}
|
|
80
|
+
if ($down) {
|
|
81
|
+
Write-Host "JobFinder parado. Log preservado em $logFile" -ForegroundColor Green
|
|
82
|
+
exit 0
|
|
83
|
+
}
|
|
84
|
+
Write-Host "A porta $Port ainda responde. Verifique o log em $logFile" -ForegroundColor Yellow
|
|
85
|
+
exit 1
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (Test-JobFinderUp -Port $Port) {
|
|
89
|
+
Write-Host "JobFinder ja esta rodando em http://127.0.0.1:$Port" -ForegroundColor Green
|
|
90
|
+
exit 0
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Write-Host "Iniciando o JobFinder em background ($label, porta $Port)..." -ForegroundColor Cyan
|
|
94
|
+
$env:JOBFINDER_MODE = "daemon"
|
|
95
|
+
Start-Process -FilePath $exe -ArgumentList ($cliArgs + @("--daemon", "--port", "$Port")) -WindowStyle Hidden
|
|
96
|
+
|
|
97
|
+
if (Wait-JobFinderUp -Port $Port -Seconds 40) {
|
|
98
|
+
Write-Host ""
|
|
99
|
+
Write-Host "JobFinder rodando em background: http://127.0.0.1:$Port" -ForegroundColor Green
|
|
100
|
+
Write-Host "Log : $logFile" -ForegroundColor Gray
|
|
101
|
+
Write-Host "Parar : .\start-windows.ps1 -Stop (ou: taskkill /F /IM node.exe)" -ForegroundColor Gray
|
|
102
|
+
exit 0
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Write-Host ""
|
|
106
|
+
Write-Host "O daemon nao respondeu em http://127.0.0.1:$Port/api/health." -ForegroundColor Red
|
|
107
|
+
Write-Host "Verifique o log em $logFile" -ForegroundColor Yellow
|
|
108
|
+
exit 1
|