當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。