本文整理汇总了PHP中Symfony\Component\Process\Process::isTerminated方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::isTerminated方法的具体用法?PHP Process::isTerminated怎么用?PHP Process::isTerminated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\Process
的用法示例。
在下文中一共展示了Process::isTerminated方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wait
/**
* {@inheritdoc}
*/
public function wait(Process $process)
{
$start = microtime(true);
$end = $start + $this->timeout / 1000;
while (!$process->isTerminated() && microtime(true) < $end) {
usleep(self::TICK * 1000);
}
if ($process->isRunning()) {
$callback = $this->callback;
$callback();
}
$process->wait();
}
示例2: handleProcess
/**
* @return bool
*/
private function handleProcess(Process $process)
{
if ($process->isStarted()) {
if ($process->isTerminated()) {
$this->running--;
return true;
}
return false;
}
// Only start a new process if we haven't reached the limit yet.
if ($this->running < $this->config->getProcessAsyncLimit()) {
$process->start();
$this->running++;
}
return false;
}
示例3: testLockingFunctionality
public function testLockingFunctionality()
{
if (!class_exists('AppKernel')) {
$this->markTestSkipped("This test does only work if a full application is installed (including AppKernel class");
}
$commandName = $this->getCommand()->getName();
$reflector = new \ReflectionClass(\AppKernel::class);
$appDirectory = dirname($reflector->getFileName());
// start commands in a separate processes
$process1 = new Process("php {$appDirectory}/console {$commandName} --env=test");
$process2 = new Process("php {$appDirectory}/console {$commandName} --env=test");
$process1->start();
$process2->start();
// wait until both processes have terminated
while (!$process1->isTerminated() || !$process2->isTerminated()) {
usleep(10);
}
$this->assertContains('The command is already running in another process.', $process2->getOutput() . $process1->getOutput());
}
示例4: basicProcess
/**
* @param string $command
* @param OutputInterface $output
* @param callable|null $callback A valid PHP callback
*/
protected function basicProcess($command, OutputInterface $output, $callback = null)
{
$process = new Process($command);
$process->setTimeout(600);
$output->writeln($this->helper->formatSection('Executing', $process->getCommandLine(), 'comment'));
$process->start();
$process->wait(function ($type, $buffer) use($output) {
if (Process::ERR == $type) {
$output->write($this->helper->formatSection('Error', $buffer, 'error'));
} else {
$output->write($this->helper->formatSection('Progress', $buffer, 'comment'));
}
});
if ($process->isTerminated()) {
$output->writeln($this->helper->formatSection('Finishing', $process->getCommandLine(), 'comment'));
if (null !== $callback) {
$callback();
}
}
}
示例5: isDoneRunning
/**
* Check if the process has terminated.
*
* @return bool
*/
public function isDoneRunning()
{
return $this->process->isTerminated();
}
示例6: startServer
/**
* @param $address
* @param $environment
*/
protected function startServer()
{
$publicDir = $this->getApplication()->getWorkingPath() . DS . 'public';
$shellCommand = $this->getBaseCommand();
$process = new Process($shellCommand, $publicDir);
if ($this->getInput()->getOption('background')) {
$process->disableOutput();
$process->start();
$processId = $this->getProcessId();
$this->getApplication()->getConfig()->setOption('server', ['pid' => $processId, 'address' => $address = 'http://' . $this->getAddress()]);
$this->getOutput()->writeln($this->info('Server has been started at ' . $address));
} else {
while ($process instanceof Process) {
if (!$process->isStarted()) {
$process->start();
continue;
}
echo $process->getIncrementalOutput();
echo $process->getIncrementalErrorOutput();
if (!$process->isRunning() || $process->isTerminated()) {
$process = false;
$this->getOutput()->writeln("");
$this->getOutput()->writeln($this->info('Server has been stopped.'));
}
sleep(1);
}
}
}