# Start the daily report scheduler (generate @ 08:50, push @ 09:00 by default) # Usage: # .\run-scheduler.ps1 # .\run-scheduler.ps1 -DryRun # .\run-scheduler.ps1 -Once param( [switch]$DryRun, [switch]$Once ) $ErrorActionPreference = "Stop" $Root = Split-Path -Parent $MyInvocation.MyCommand.Path Set-Location $Root function Import-DotEnvFile { param([string]$Path) if (-not (Test-Path $Path)) { return } Get-Content $Path -Encoding UTF8 | ForEach-Object { if ($_ -match '^\s*#' -or $_ -notmatch '=') { return } $pair = $_ -split '=', 2 if ($pair.Count -eq 2) { $name = $pair[0].Trim() $value = $pair[1].Trim().Trim('"').Trim("'") if ($name -and $value) { Set-Item -Path "Env:$name" -Value $value } } } } Import-DotEnvFile (Join-Path $Root ".env") Import-DotEnvFile (Join-Path $Root ".env.local") $args = @("python", "-m", "daily", "schedule") if ($DryRun) { $args += "--dry-run" } if ($Once) { $args += "--once" } Write-Host "Starting scheduler: $($args -join ' ')" & $args[0] $args[1..($args.Length - 1)] if ($LASTEXITCODE -ne 0) { throw "scheduler failed with exit code $LASTEXITCODE" }