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