feat: complete production workflow migration
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
[Unit]
|
||||
Description=GYXX Flow Python Scheduler
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gyxx-flow
|
||||
Group=gyxx-flow
|
||||
WorkingDirectory=/opt/gyxx-flow
|
||||
Environment=PYTHONUTF8=1
|
||||
Environment=GYXX_PROJECT_ROOT=/opt/gyxx-flow
|
||||
Environment=GYXX_DATA_ROOT=/var/lib/gyxx-flow
|
||||
EnvironmentFile=-/etc/gyxx-flow/gyxx-flow.env
|
||||
ExecStart=/opt/gyxx-flow/.venv/bin/python -m gyxx_flow schedule run
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
TimeoutStopSec=90s
|
||||
KillSignal=SIGTERM
|
||||
NoNewPrivileges=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,26 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: gyxx-flow-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: gyxx_super_data
|
||||
POSTGRES_USER: gyxx_flow
|
||||
POSTGRES_PASSWORD: ${GYXX_POSTGRES_PASSWORD:?set GYXX_POSTGRES_PASSWORD}
|
||||
ports:
|
||||
- "127.0.0.1:5432:5432"
|
||||
volumes:
|
||||
- gyxx_flow_postgres:/var/lib/postgresql/data
|
||||
- ../src/gyxx_flow/modules/content_marketing/data/tools/schema_gyxx_super_data.sql:/docker-entrypoint-initdb.d/10-content-marketing.sql:ro
|
||||
- ../src/gyxx_flow/modules/product_commerce/db/schema.sql:/docker-entrypoint-initdb.d/20-product-commerce.sql:ro
|
||||
- ../src/gyxx_flow/modules/shop_intelligence/db/schema.sql:/docker-entrypoint-initdb.d/30-shop-intelligence.sql:ro
|
||||
- ../src/gyxx_flow/modules/supply_chain/orchestrator/sql/001_init.sql:/docker-entrypoint-initdb.d/40-supply-chain.sql:ro
|
||||
- ../src/gyxx_flow/modules/supply_chain/orchestrator/sql/002_workflow_v2.sql:/docker-entrypoint-initdb.d/41-supply-chain-v2.sql:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 20
|
||||
|
||||
volumes:
|
||||
gyxx_flow_postgres:
|
||||
@@ -0,0 +1,50 @@
|
||||
# Legacy Windows compatibility only.
|
||||
# NSSM supervises the single Python scheduler process; this script never creates
|
||||
# Windows Task Scheduler entries and does not own business schedule rules.
|
||||
param(
|
||||
[string]$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path,
|
||||
[string]$DataRoot = "",
|
||||
[string]$ServiceName = "gyxx-flow-scheduler",
|
||||
[string]$NssmPath = "nssm.exe"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$project = (Resolve-Path -LiteralPath $ProjectRoot).Path
|
||||
if ([string]::IsNullOrWhiteSpace($DataRoot)) {
|
||||
$DataRoot = Join-Path $project "var"
|
||||
}
|
||||
$data = [IO.Path]::GetFullPath($DataRoot)
|
||||
$python = Join-Path $project ".venv\Scripts\python.exe"
|
||||
if (-not (Test-Path -LiteralPath $python -PathType Leaf)) {
|
||||
throw "Python environment not found: $python"
|
||||
}
|
||||
$nssm = (Get-Command $NssmPath -ErrorAction Stop).Source
|
||||
$serviceLogRoot = Join-Path $data "logs\scheduler-service"
|
||||
New-Item -ItemType Directory -Path $serviceLogRoot -Force | Out-Null
|
||||
|
||||
function Invoke-Nssm([string[]]$Arguments) {
|
||||
& $nssm @Arguments
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "NSSM failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-Nssm -Arguments @("install", $ServiceName, $python)
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppDirectory", $project)
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppParameters", "-m gyxx_flow schedule run")
|
||||
Invoke-Nssm -Arguments @(
|
||||
"set", $ServiceName, "AppEnvironmentExtra",
|
||||
"GYXX_PROJECT_ROOT=$project", "GYXX_DATA_ROOT=$data", "PYTHONUTF8=1"
|
||||
)
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppStdout", (Join-Path $serviceLogRoot "service.log"))
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppStderr", (Join-Path $serviceLogRoot "service-error.log"))
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppRotateFiles", "1")
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppRotateBytes", "10485760")
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "AppExit", "Default", "Restart")
|
||||
Invoke-Nssm -Arguments @("set", $ServiceName, "Start", "SERVICE_AUTO_START")
|
||||
|
||||
Write-Host "Service installed: $ServiceName"
|
||||
Write-Host "Before starting it, set the Log On account and production environment as documented."
|
||||
Write-Host "Start with: nssm start $ServiceName"
|
||||
@@ -0,0 +1,20 @@
|
||||
# Legacy Windows compatibility only. This removes the NSSM process supervisor;
|
||||
# project data, browser state, and Python scheduler state are preserved.
|
||||
param(
|
||||
[string]$ServiceName = "gyxx-flow-scheduler",
|
||||
[string]$NssmPath = "nssm.exe"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version Latest
|
||||
$nssm = (Get-Command $NssmPath -ErrorAction Stop).Source
|
||||
|
||||
& $nssm stop $ServiceName
|
||||
if ($LASTEXITCODE -notin @(0, 3)) {
|
||||
throw "Unable to stop service $ServiceName (exit code $LASTEXITCODE)"
|
||||
}
|
||||
& $nssm remove $ServiceName confirm
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Unable to remove service $ServiceName (exit code $LASTEXITCODE)"
|
||||
}
|
||||
Write-Host "Service removed. Project data and scheduler state were preserved."
|
||||
Reference in New Issue
Block a user