当前位置: 首页>>代码示例>>PHP>>正文


PHP Process::isStarted方法代码示例

本文整理汇总了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.</>');
 }
开发者ID:vdrizheruk,项目名称:php-subprocess-example,代码行数:27,代码来源:MainCommand.php

示例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;
 }
开发者ID:phpro,项目名称:grumphp,代码行数:19,代码来源:AsyncProcessRunner.php

示例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);
         }
     }
 }
开发者ID:narno,项目名称:phpoole,代码行数:47,代码来源:Serve.php

示例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;
 }
开发者ID:provisioner-io,项目名称:elevate,代码行数:29,代码来源:Connection.php

示例5: isStarted

 public function isStarted()
 {
     return $this->process->isStarted() && $this->portIsAcceptingConnections();
 }
开发者ID:ciaranmcnulty,项目名称:behat-localwebserverextension,代码行数:4,代码来源:BuiltInWebserverController.php

示例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);
         }
     }
 }
开发者ID:bluzphp,项目名称:bluzman,代码行数:32,代码来源:StartCommand.php


注:本文中的Symfony\Component\Process\Process::isStarted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。