start_water.ps1 1.1 KB

123456789101112131415161718
  1. param([string]$PhpBinary = (Get-Command php).Source)
  2. $ErrorActionPreference = 'Stop'
  3. $projectPath = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
  4. $oldScanPath = $env:PHP_INI_SCAN_DIR
  5. try {
  6. $modules = & $PhpBinary -m
  7. if ($LASTEXITCODE -ne 0) { throw 'PHP module check failed' }
  8. if ($modules -notcontains 'mbstring') {
  9. $extraIni = Join-Path $projectPath 'config\php'
  10. $env:PHP_INI_SCAN_DIR = if ($oldScanPath) { "$oldScanPath;$extraIni" } else { $extraIni }
  11. $modules = & $PhpBinary -m
  12. if ($modules -notcontains 'mbstring') { throw 'PHP mbstring extension could not be loaded' }
  13. }
  14. $process = Start-Process -FilePath $PhpBinary -ArgumentList @('windows.php','start') -WorkingDirectory $projectPath -WindowStyle Hidden -PassThru -RedirectStandardOutput (Join-Path $projectPath 'runtime\water-start.stdout.log') -RedirectStandardError (Join-Path $projectPath 'runtime\water-start.stderr.log')
  15. Write-Output "Started project PHP supervisor PID $($process.Id), mbstring enabled for child workers."
  16. } finally {
  17. $env:PHP_INI_SCAN_DIR = $oldScanPath
  18. }