本文整理汇总了PHP中Symfony\Component\Process\Process::isStarted方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::isStarted方法的具体用法?PHP Process::isStarted怎么用?PHP Process::isStarted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\Process
的用法示例。
在下文中一共展示了Process::isStarted方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$channels = [];
$maxChannels = $input->getArgument('CPUs');
$exampleArray = $this->getExampleArray();
$output->writeln('<fg=green>Start example process</>');
while (count($exampleArray) > 0 || count($channels) > 0) {
foreach ($channels as $key => $channel) {
if ($channel instanceof Process && $channel->isTerminated()) {
unset($channels[$key]);
}
}
if (count($channels) >= $maxChannels) {
continue;
}
if (!($item = array_pop($exampleArray))) {
continue;
}
$process = new Process(sprintf('php index.php example:sub-process %s', $item), __DIR__ . '/../../../');
$process->start();
if (!$process->isStarted()) {
throw new \Exception($process->getErrorOutput());
}
$channels[] = $process;
}
$output->writeln('<bg=green;fg=black>Done.</>');
}
示例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: processCommand
public function processCommand()
{
$this->watch = $this->getRoute()->getMatchedParam('watch', false);
$this->fileSystem = new Filesystem();
$this->setUpServer();
$command = sprintf('php -S %s:%d -t %s %s', 'localhost', '8000', $this->getPath() . '/' . $this->getPHPoole()->getOption('output.dir'), sprintf('%s/.phpoole/router.php', $this->getPath()));
$this->wlAnnonce(sprintf('Starting server (http://%s:%d)...', 'localhost', '8000'));
$process = new Process($command);
if (!$process->isStarted()) {
// write changes cache
if ($this->watch) {
$finder = new Finder();
$finder->files()->name('*.md')->name('*.html')->in([$this->getPath() . '/' . $this->getPHPoole()->getOption('content.dir'), $this->getPath() . '/' . $this->getPHPoole()->getOption('layouts.dir')]);
if (is_dir($this->getPath() . '/' . $this->getPHPoole()->getOption('themes.dir'))) {
$finder->in($this->getPath() . '/' . $this->getPHPoole()->getOption('themes.dir'));
}
$resourceCache = new ResourceCacheMemory();
$resourceWatcher = new ResourceWatcher($resourceCache);
$resourceWatcher->setFinder($finder);
$this->fileSystem->dumpFile($this->getPath() . '/.phpoole/watch.flag', '');
}
// start server
try {
$process->start();
Plateform::openBrowser('http://localhost:8000');
while ($process->isRunning()) {
// watch changes?
if ($this->watch) {
$resourceWatcher->findChanges();
if ($resourceWatcher->hasChanges()) {
$this->fileSystem->dumpFile($this->getPath() . '/.phpoole/changes.flag', '');
// re-generate
$this->wlAlert('Changes detected!');
$callable = new Build();
call_user_func($callable, $this->getRoute(), $this->getConsole());
}
}
usleep(1000000);
// 1 s
}
} catch (ProcessFailedException $e) {
$this->tearDownServer();
echo $e->getMessage();
exit(2);
}
}
}
示例4: execute
/**
* Execute the process (or the optional process) and handle its response ouput.
*
* @param Process $process
* @return bool
*/
public function execute(Process $process = null)
{
$this->process = $process ?: $this->getProcess();
try {
if (!$this->process->isStarted()) {
$this->process->run();
}
if ($this->process->isSuccessful()) {
$output = explode(static::BATCH_BREAK, $this->process->getOutput());
array_shift($output);
foreach ($this->batches as $index => $batch) {
$response = $output[$index];
$response = preg_replace('(^\\s+|\\s+$)', '', $response);
$batch->setProcessResponse($response);
}
return true;
}
} catch (ProcessExceptionInterface $e) {
// need to handle exceptions here.
// make sure the catch falls through to the return false.
}
return false;
}
示例5: isStarted
public function isStarted()
{
return $this->process->isStarted() && $this->portIsAcceptingConnections();
}
示例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);
}
}
}