chore: add deployment and maintenance tooling
This commit is contained in:
1 parent
18cf2e8e40
commit
8a91b4ab9c
9 files changed
+2585
No files matched your search
@@ -0,0 +1,68 @@
|
||||
param(
|
||||
[switch]$UsePm2,
|
||||
[string]$Pm2Name = "lolympus-tournament-support"
|
||||
)
|
||||
|
||||
if (-not $env:NODE_ENV) {
|
||||
$env:NODE_ENV = "dev"
|
||||
}
|
||||
|
||||
$MainScript = Join-Path $PSScriptRoot "dist/main.js"
|
||||
|
||||
if ($isMacOS -or $isLinux) {
|
||||
$env:MachineEnvFile = "$env:HOME/source/global-env-vars.txt"
|
||||
} elseif ($isWindows) {
|
||||
$env:MachineEnvFile = "$env:USERPROFILE/source/global-env-vars.txt"
|
||||
}
|
||||
|
||||
function Set-EnvFromFile {
|
||||
param([string]$Path)
|
||||
|
||||
if (-not (Test-Path $Path)) {
|
||||
throw "File not found: $Path"
|
||||
}
|
||||
|
||||
foreach ($line in Get-Content $Path) {
|
||||
if ([string]::IsNullOrWhiteSpace($line)) { continue }
|
||||
if ($line -match '^\s*#') { continue }
|
||||
|
||||
if ($line -match '^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$') {
|
||||
$key = $matches[1]
|
||||
$value = $matches[2].Trim()
|
||||
|
||||
if (
|
||||
($value.StartsWith('"') -and $value.EndsWith('"')) -or
|
||||
($value.StartsWith("'") -and $value.EndsWith("'"))
|
||||
) {
|
||||
$value = $value.Substring(1, $value.Length - 2)
|
||||
}
|
||||
|
||||
[System.Environment]::SetEnvironmentVariable($key, $value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Path $env:MachineEnvFile) {
|
||||
Set-EnvFromFile $env:MachineEnvFile
|
||||
}
|
||||
|
||||
if (-not $env:INFISICAL_CLIENT_ID) {
|
||||
Write-Error "INFISICAL_CLIENT_ID is not set."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not $env:INFISICAL_CLIENT_SECRET) {
|
||||
Write-Error "INFISICAL_CLIENT_SECRET is not set."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not $env:INFISICAL_PROJECT_ID) {
|
||||
Write-Error "INFISICAL_PROJECT_ID is not set."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ($UsePm2) {
|
||||
pm2 start $MainScript --name $Pm2Name --update-env
|
||||
} else {
|
||||
node $MainScript
|
||||
}
|
||||
Reference in new issue
Block a user