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


PHP Process::setEnhanceWindowsCompatibility方法代码示例

本文整理汇总了PHP中Symfony\Component\Process\Process::setEnhanceWindowsCompatibility方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::setEnhanceWindowsCompatibility方法的具体用法?PHP Process::setEnhanceWindowsCompatibility怎么用?PHP Process::setEnhanceWindowsCompatibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Process\Process的用法示例。


在下文中一共展示了Process::setEnhanceWindowsCompatibility方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

 /**
  * Starts a wiremock process.
  *
  * @param string $jarPath
  * @param string $logsPath
  * @param string $arguments
  *
  * @throws \Exception
  */
 public function start($ip, $port, $path, $logsPath, $debug)
 {
     $phiremockPath = is_file($path) ? $path : "{$path}/phiremock";
     $this->process = new Process($this->getCommandPrefix() . "{$phiremockPath} -i {$ip} -p {$port}" . ($debug ? ' -d' : ''));
     if ($debug) {
         echo 'Executing: ' . $this->process->getCommandLine() . PHP_EOL;
     }
     $logFile = $logsPath . DIRECTORY_SEPARATOR . self::LOG_FILE_NAME;
     $this->process->start(function ($type, $buffer) use($logFile) {
         file_put_contents($logFile, $buffer, FILE_APPEND);
     });
     $this->process->setEnhanceSigchildCompatibility(true);
     if ($this->isWindows()) {
         $this->process->setEnhanceWindowsCompatibility(true);
     }
 }
开发者ID:mcustiel,项目名称:phiremock-codeception-extension,代码行数:25,代码来源:PhiremockProcess.php

示例2: run

 public function run()
 {
     $connected = $this->start();
     $this->debug('started');
     $forks = array();
     if ($connected) {
         try {
             $this->debug('connected');
             $work = $this->work();
             $this->debug('after init work generator');
             /**
              * Until next job maximum 1 zombie process might be hanging,
              * we cleanup-up zombies when receiving next job
              */
             foreach ($work as $taskId => $payload) {
                 $this->debug('got some work');
                 $message = @unserialize($payload);
                 $processed = true;
                 if (!$message instanceof \BackQ\Message\Process) {
                     $work->send($processed);
                     @error_log('Worker does not support payload of: ' . gettype($message));
                 } else {
                     try {
                         $this->debug('job timeout=' . $message->getTimeout());
                         /**
                          * Enclosure in anonymous function
                          *
                          * ZOMBIE WARNING
                          * @see http://stackoverflow.com/questions/29037880/start-a-background-symfony-process-from-symfony-console
                          *
                          * All the methods that returns results or use results probed by proc_get_status might be wrong
                          * @see https://github.com/symfony/symfony/issues/5759
                          *
                          * @tip use PHP_BINARY for php path
                          */
                         $run = function () use($message) {
                             $this->debug('launching ' . $message->getCommandline());
                             $process = new \Symfony\Component\Process\Process($message->getCommandline(), $message->getCwd(), $message->getEnv(), $message->getInput(), $message->getTimeout(), $message->getOptions());
                             /**
                              * no win support here
                              */
                             $process->setEnhanceWindowsCompatibility(false);
                             /**
                              * ultimately also disables callbacks
                              */
                             $process->disableOutput();
                             /**
                              * Execute call
                              * proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
                              *
                              * @throws RuntimeException When process can't be launched
                              */
                             $process->start();
                             return $process;
                         };
                         /**
                          * Loop over previous forks and gracefully stop/close them,
                          * doing this before pushing new fork in the pool
                          */
                         if (!empty($forks)) {
                             foreach ($forks as $f) {
                                 try {
                                     /**
                                      * here we PREVENTs ZOMBIES
                                      * isRunning itself closes the process if its ended (not running)
                                      * use `pstree` to look out for zombies
                                      */
                                     if ($f->isRunning()) {
                                         /**
                                          * If its still running, check the timeouts
                                          */
                                         $f->checkTimeout();
                                     }
                                 } catch (ProcessTimedOutException $e) {
                                 }
                             }
                         }
                         $forks[] = $run();
                     } catch (\Exception $e) {
                         /**
                          * Not caching exceptions, just launching processes async
                          */
                         @error_log('Process worker failed to run: ' . $e->getMessage());
                     }
                     $work->send(true === $processed);
                     if (true !== $processed) {
                         /**
                          * Worker not reliable, quitting
                          */
                         throw new \RuntimeException('Worker not reliable, failed to process task: ' . $processed);
                     }
                 }
             }
         } catch (\Exception $e) {
             @error_log('Process worker exception: ' . $e->getMessage());
         }
     }
     /**
      * Keep the references to forks until the end of execution,
      * attempt to close the forks nicely,
//.........这里部分代码省略.........
开发者ID:sshilko,项目名称:backq,代码行数:101,代码来源:AProcess.php


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