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


PHP ProcessBuilder::setTimeout方法代码示例

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


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

示例1: buildProcess

 /**
  * Build a Process to run tivodecode decoding a file with a MAK
  *
  * @param string $mak    TiVo's Media Access Key
  * @param string $input  Where the encoded TiVo file is
  * @param string $output Where the decoded MPEG file goes
  *
  * @return Process
  */
 protected function buildProcess($mak, $input, $output)
 {
     $this->builder->setPrefix('/usr/local/bin/tivodecode');
     $this->builder->setArguments([$input, '--mak=' . $mak, '--no-verify', '--out=' . $output]);
     $this->builder->setTimeout(null);
     return $this->builder->getProcess();
 }
开发者ID:jimlind,项目名称:tivo-php,代码行数:16,代码来源:VideoDecoder.php

示例2: buildProcess

 /**
  * Build a Process to run avahi-browse looking for TiVo on TCP
  *
  * @return Process
  */
 protected function buildProcess()
 {
     $this->builder->setPrefix('avahi-browse');
     $this->builder->setArguments(['--ignore-local', '--resolve', '--terminate', '_tivo-videos._tcp']);
     $this->builder->setTimeout(60);
     return $this->builder->getProcess();
 }
开发者ID:jimlind,项目名称:tivo-php,代码行数:12,代码来源:TiVoFinder.php

示例3: testNullTimeout

 public function testNullTimeout()
 {
     $pb = new ProcessBuilder();
     $pb->setTimeout(10);
     $pb->setTimeout(null);
     $r = new \ReflectionObject($pb);
     $p = $r->getProperty('timeout');
     $p->setAccessible(true);
     $this->assertNull($p->getValue($pb));
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:10,代码来源:ProcessBuilderTest.php

示例4: __construct

 public function __construct(LoggerInterface $logger = null, ProcessBuilder $builder, MessageProviderInterface $provider, MessagePublisherInterface $publisher, $commandPath, $environment, $verbosity = OutputInterface::VERBOSITY_NORMAL)
 {
     $this->logger = $logger ?: new NullLogger();
     $this->builder = $builder;
     $this->provider = $provider;
     $this->publisher = $publisher;
     $this->verbosity = $verbosity;
     $this->commandPath = $commandPath;
     $this->environment = $environment;
     $this->builder->setTimeout(null);
 }
开发者ID:Wisembly,项目名称:AMQPBundle,代码行数:11,代码来源:CommandProcessor.php

示例5: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch($scratchDir, LoggerInterface $logger)
 {
     $logger->info(sprintf('Running mysqldump for: %s', $this->database));
     $processBuilder = new ProcessBuilder();
     $processBuilder->setTimeout($this->timeout);
     if (null !== $this->sshHost && null !== $this->sshUser) {
         $processBuilder->add('ssh');
         $processBuilder->add(sprintf('%s@%s', $this->sshUser, $this->sshHost));
         $processBuilder->add(sprintf('-p %s', $this->sshPort));
     }
     $processBuilder->add('mysqldump');
     $processBuilder->add(sprintf('-u%s', $this->user));
     if (null !== $this->host) {
         $processBuilder->add(sprintf('-h%s', $this->host));
     }
     if (null !== $this->password) {
         $processBuilder->add(sprintf('-p%s', $this->password));
     }
     $processBuilder->add($this->database);
     $process = $processBuilder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     file_put_contents(sprintf('%s/%s.sql', $scratchDir, $this->database), $process->getOutput());
 }
开发者ID:kachkaev,项目名称:php-backup,代码行数:29,代码来源:MySqlDumpSource.php

示例6: start

 /**
  * @throws \RuntimeException if server could not be started within $this->timeout seconds
  */
 public function start()
 {
     if ($this->isRunning()) {
         return;
     }
     $processBuilder = new ProcessBuilder(['/usr/bin/php', '-S', "{$this->host}:{$this->port}", '-t', $this->webRoot]);
     $processBuilder->setTimeout(10);
     $this->serverProcess = $processBuilder->getProcess();
     $this->serverProcess->start();
     // server needs some time to boot up
     $serverIsBooting = true;
     $timeoutAt = time() + $this->timeout;
     while ($this->serverProcess->isRunning() && $serverIsBooting) {
         try {
             $socket = fsockopen($this->host, $this->port);
             if ($socket) {
                 $serverIsBooting = false;
             }
         } catch (\Exception $ex) {
             // server not ready
             if ($timeoutAt < time()) {
                 throw new \RuntimeException("Could not start Web Server [host = {$this->host}; port = {$this->port}; web root = {$this->webRoot}]");
             }
         }
         usleep(10);
     }
 }
开发者ID:paq85,项目名称:WebServer,代码行数:30,代码来源:PhpBuiltInWebServer.php

示例7: createProcessBuilder

 /**
  * Creates a new process builder.
  *
  * @param array $arguments An optional array of arguments
  *
  * @return ProcessBuilder A new process builder
  */
 protected function createProcessBuilder(array $arguments = array())
 {
     $pb = new ProcessBuilder($arguments);
     if (null !== $this->timeout) {
         $pb->setTimeout($this->timeout);
     }
     return $pb;
 }
开发者ID:icedevelopment,项目名称:compressor-bundle,代码行数:15,代码来源:BaseProcessCompressor.php

示例8: setTimeout

 /**
  * @inheritdoc
  */
 public function setTimeout($timeout)
 {
     $this->timeout = $timeout;
     if (!static::$emulateSfLTS) {
         $this->builder->setTimeout($this->timeout);
     }
     return $this;
 }
开发者ID:fluxuator,项目名称:BinaryDriver,代码行数:11,代码来源:ProcessBuilderFactory.php

示例9: runCommand

 /**
  * Launches a command as a separate process.
  *
  * The '--process-timeout' parameter can be used to set the process timeout
  * in seconds. Default timeout is 300 seconds.
  * If '--ignore-errors' parameter is specified any errors are ignored;
  * otherwise, an exception is raises if an error happened.
  * If '--disable-cache-sync' parameter is specified a synchronization of caches between current
  * process and its child processes are disabled.
  *
  * @param string               $command
  * @param array                $params
  * @param LoggerInterface|null $logger
  *
  * @return integer The exit status code
  *
  * @throws \RuntimeException if command failed and '--ignore-errors' parameter is not specified
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function runCommand($command, $params = [], LoggerInterface $logger = null)
 {
     $params = array_merge(['command' => $command], $params);
     if ($this->env && $this->env !== 'dev') {
         $params['--env'] = $this->env;
     }
     $ignoreErrors = false;
     if (array_key_exists('--ignore-errors', $params)) {
         $ignoreErrors = true;
         unset($params['--ignore-errors']);
     }
     $pb = new ProcessBuilder();
     $pb->add($this->getPhp())->add($this->consoleCmdPath);
     if (array_key_exists('--process-timeout', $params)) {
         $pb->setTimeout($params['--process-timeout']);
         unset($params['--process-timeout']);
     } else {
         $pb->setTimeout($this->defaultTimeout);
     }
     $disableCacheSync = false;
     if (array_key_exists('--disable-cache-sync', $params)) {
         $disableCacheSync = $params['--disable-cache-sync'];
         unset($params['--disable-cache-sync']);
     }
     foreach ($params as $name => $val) {
         $this->processParameter($pb, $name, $val);
     }
     $process = $pb->inheritEnvironmentVariables(true)->getProcess();
     if (!$logger) {
         $logger = new NullLogger();
     }
     $exitCode = $process->run(function ($type, $data) use($logger) {
         if ($type === Process::ERR) {
             $logger->error($data);
         } else {
             $logger->notice($data);
         }
     });
     // synchronize all data caches
     if ($this->dataCacheManager && !$disableCacheSync) {
         $this->dataCacheManager->sync();
     }
     $this->processResult($exitCode, $ignoreErrors, $logger);
     return $exitCode;
 }
开发者ID:nmallare,项目名称:platform,代码行数:65,代码来源:CommandExecutor.php

示例10: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Server running on <info>http://localhost:8000/</info>');
     $builder = new ProcessBuilder([PHP_BINARY, '-S', 'localhost:8000', '-t', 'web/', sprintf('web/%s.php', $input->getOption('env'))]);
     $builder->setTimeout(null);
     $builder->getProcess()->run(function ($type, $buffer) use($output) {
         $output->write($buffer);
     });
 }
开发者ID:hongshuan,项目名称:avid-candidate-challenge-busted,代码行数:15,代码来源:ServerRun.php

示例11: createProcess

 /**
  * @param array $commands
  * @param \Hshn\NpmBundle\Npm\ConfigurationInterface $configuration
  * @return \Symfony\Component\Process\Process
  */
 private function createProcess(array $commands, ConfigurationInterface $configuration)
 {
     $builder = new ProcessBuilder([$this->binPath]);
     $builder->setWorkingDirectory($configuration->getDirectory());
     $builder->setTimeout(600);
     foreach ($commands as $command) {
         $builder->add($command);
     }
     return $builder->getProcess();
 }
开发者ID:hshn,项目名称:HshnNpmBundle,代码行数:15,代码来源:Npm.php

示例12: startWebServer

 private function startWebServer(InputInterface $input, OutputInterface $output, $targetDirectory)
 {
     $builder = new ProcessBuilder([PHP_BINARY, '-S', $input->getArgument('address')]);
     $builder->setWorkingDirectory($targetDirectory);
     $builder->setTimeout(null);
     $process = $builder->getProcess();
     $process->start();
     $output->writeln(sprintf("Server running on <comment>%s</comment>", $input->getArgument('address')));
     return $process;
 }
开发者ID:snipe,项目名称:Couscous,代码行数:10,代码来源:PreviewCommand.php

示例13: getProcessBuilder

 /**
  * {@inheritdoc}
  */
 public function getProcessBuilder(array $arguments, $timeout = self::DEFAULT_PROCESS_TIMEOUT)
 {
     $builder = new ProcessBuilder();
     $builder->setPrefix($this->getPhpBinary());
     $builder->setWorkingDirectory($this->getCwd());
     $builder->setArguments($arguments);
     $builder->setTimeout($timeout);
     $builder->inheritEnvironmentVariables(true);
     return $builder;
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:13,代码来源:EnvironmentHelper.php

示例14: runCommand

 /**
  * Launches a command.
  * If '--process-isolation' parameter is specified the command will be launched as a separate process.
  * In this case you can parameter '--process-timeout' to set the process timeout
  * in seconds. Default timeout is 60 seconds.
  * If '--ignore-errors' parameter is specified any errors are ignored;
  * otherwise, an exception is raises if an error happened.
  *
  * @param string $command
  * @param array  $params
  * @return CommandExecutor
  * @throws \RuntimeException if command failed and '--ignore-errors' parameter is not specified
  */
 public function runCommand($command, $params = array())
 {
     $params = array_merge(array('command' => $command, '--no-debug' => true), $params);
     if ($this->env && $this->env !== 'dev') {
         $params['--env'] = $this->env;
     }
     $ignoreErrors = false;
     if (array_key_exists('--ignore-errors', $params)) {
         $ignoreErrors = true;
         unset($params['--ignore-errors']);
     }
     if (array_key_exists('--process-isolation', $params)) {
         unset($params['--process-isolation']);
         $phpFinder = new PhpExecutableFinder();
         $php = $phpFinder->find();
         $pb = new ProcessBuilder();
         $pb->add($php)->add($_SERVER['argv'][0]);
         if (array_key_exists('--process-timeout', $params)) {
             $pb->setTimeout($params['--process-timeout']);
             unset($params['--process-timeout']);
         }
         foreach ($params as $param => $val) {
             if ($param && '-' === $param[0]) {
                 if ($val === true) {
                     $pb->add($param);
                 } elseif (is_array($val)) {
                     foreach ($val as $value) {
                         $pb->add($param . '=' . $value);
                     }
                 } else {
                     $pb->add($param . '=' . $val);
                 }
             } else {
                 $pb->add($val);
             }
         }
         $process = $pb->inheritEnvironmentVariables(true)->getProcess();
         $output = $this->output;
         $process->run(function ($type, $data) use($output) {
             $output->write($data);
         });
         $ret = $process->getExitCode();
     } else {
         $this->application->setAutoExit(false);
         $ret = $this->application->run(new ArrayInput($params), $this->output);
     }
     if (0 !== $ret) {
         if ($ignoreErrors) {
             $this->output->writeln(sprintf('<error>The command terminated with an error code: %u.</error>', $ret));
         } else {
             throw new \RuntimeException(sprintf('The command terminated with an error status: %u.', $ret));
         }
     }
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:68,代码来源:CommandExecutor.php

示例15: runCommand

 /**
  * Launches a command.
  * If '--process-isolation' parameter is specified the command will be launched as a separate process.
  * In this case you can parameter '--process-timeout' to set the process timeout
  * in seconds. Default timeout is 300 seconds.
  * If '--ignore-errors' parameter is specified any errors are ignored;
  * otherwise, an exception is raises if an error happened.
  *
  * @param string $command
  * @param array  $params
  * @return CommandExecutor
  * @throws \RuntimeException if command failed and '--ignore-errors' parameter is not specified
  */
 public function runCommand($command, $params = [])
 {
     $params = array_merge(['command' => $command], $params);
     if ($this->env && $this->env !== 'dev') {
         $params['--env'] = $this->env;
     }
     $ignoreErrors = false;
     if (array_key_exists('--ignore-errors', $params)) {
         $ignoreErrors = true;
         unset($params['--ignore-errors']);
     }
     if (array_key_exists('--process-isolation', $params)) {
         unset($params['--process-isolation']);
         $pb = new ProcessBuilder();
         $pb->add($this->getPhp())->add($_SERVER['argv'][0]);
         if (array_key_exists('--process-timeout', $params)) {
             $pb->setTimeout($params['--process-timeout']);
             unset($params['--process-timeout']);
         } else {
             $pb->setTimeout($this->defaultTimeout);
         }
         foreach ($params as $name => $val) {
             $this->processParameter($pb, $name, $val);
         }
         $process = $pb->inheritEnvironmentVariables(true)->getProcess();
         $output = $this->output;
         $process->run(function ($type, $data) use($output) {
             $output->write($data);
         });
         $this->lastCommandExitCode = $process->getExitCode();
         // synchronize all data caches
         if ($this->dataCacheManager) {
             $this->dataCacheManager->sync();
         }
     } else {
         $this->application->setAutoExit(false);
         $this->lastCommandExitCode = $this->application->run(new ArrayInput($params), $this->output);
     }
     $this->processResult($ignoreErrors);
     return $this;
 }
开发者ID:xamin123,项目名称:platform,代码行数:54,代码来源:CommandExecutor.php


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