<?php
namespace Engine\Os\Command; class AsyncPhpScript extends \Engine\Os\Command\Process { protected $priority = 19; protected $arguments = ""; public function __construct($command=NULL) { $this->command = escapeshellarg(APP_REAL_PATH.'disp.php'); } public function setPriority($priority) { $this->priority = $priority; return $this; } public function setArguments($arguments) { $this->arguments = $arguments; return $this; } public function addArgument($option, $value=null) { $this->arguments.= sprintf(" %s=%s", $option, escapeshellarg($value)); return $this; } protected function doRun($command, $outputFile, $async, $captureErrors) :void { $php = "php -f"; $nice = ''; if ($this->priority) { $nice = "nice -n {$this->priority}"; } $command = trim("{$nice} {$php} {$this->command} {$this->arguments}"); parent::doRun($command, $outputFile, $async, $captureErrors); } }