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


PHP Process::setTimeout方法代码示例

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


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

示例1: setUpPhpServer

 private static function setUpPhpServer()
 {
     self::$process = new Process('php -S [::1]:8999', __DIR__ . '/../../Resources/Scripts');
     self::$process->setTimeout(1);
     self::$process->start();
     usleep(100000);
 }
开发者ID:xsolla,项目名称:xsolla-sdk-php,代码行数:7,代码来源:ServerTest.php

示例2: startDemoServer

 /**
  * Starts the internal PHP server using excerpts from my (awesome)
  * travel blog as the docroot.
  */
 public function startDemoServer()
 {
     $docRoot = realpath(__DIR__ . '/../../demo/mike-on-a-bike.com');
     $this->demoServerProcess = new Process('php -S ' . self::HOST . ' -t ' . $docRoot);
     $this->demoServerProcess->setTimeout(3600);
     $this->demoServerProcess->start();
 }
开发者ID:mihaeu,项目名称:tarantula,代码行数:11,代码来源:DemoServer.php

示例3: runLocally

 /**
  * Running a command on local machine.
  * @param  string $commandline
  * @param  array  $options
  * @return ProcessResult
  */
 public function runLocally($commandline, $options = array())
 {
     if (is_array($commandline)) {
         $os = php_uname('s');
         if (preg_match('/Windows/i', $os)) {
             $commandline = implode(" & ", $commandline);
         } else {
             $commandline = implode(" && ", $commandline);
         }
     }
     $this->runtimeTask->getOutput()->writeln($this->getLocalInfoPrefix() . "<info>Run: </info>{$commandline}");
     $realCommand = $this->compileRealCommand($commandline, $options, TRUE);
     if ($this->runtimeTask->getOutput()->isVeryVerbose()) {
         $this->runtimeTask->getOutput()->writeln($this->getLocalInfoPrefix() . "<info>Real command: </info>{$realCommand}");
     }
     $self = $this;
     $symfonyProcess = new SymfonyProcess($realCommand);
     if (isset($options["timeout"])) {
         $symfonyProcess->setTimeout($options["timeout"]);
     } else {
         $symfonyProcess->setTimeout(null);
     }
     $resultContent = null;
     $returnCode = $symfonyProcess->run(function ($type, $buffer) use($self, &$resultContent) {
         $self->getRuntimeTask()->getOutput()->write($buffer);
         $resultContent .= $buffer;
     });
     return new ProcessResult($returnCode, $resultContent);
 }
开发者ID:kohkimakimoto,项目名称:altax,代码行数:35,代码来源:Process.php

示例4: testNullTimeout

 public function testNullTimeout()
 {
     $p = new Process('');
     $p->setTimeout(10);
     $p->setTimeout(null);
     $this->assertNull($p->getTimeout());
 }
开发者ID:newism,项目名称:symfony,代码行数:7,代码来源:ProcessTest.php

示例5: exec

 /**
  * Executes the command $cmd
  *
  * @param string $cmd
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param bool $silent
  * @param bool $tty
  * @return string|void
  */
 public function exec($cmd, $output = null, $silent = FALSE, $tty = FALSE)
 {
     $process = new Process($cmd);
     if ($tty) {
         $process->setTty(TRUE);
     }
     $process->setTimeout(null);
     if (!$silent && $output) {
         $output->writeln($this->messageService->lightGray('-------------------------------------------------'));
         $output->writeln($this->messageService->lightGray('Executing: ' . $cmd));
         $messageService = $this->messageService;
         $process->setTimeout(3600);
         $process->start();
         $process->wait(function ($type, $buffer) use($output, $messageService) {
             if (Process::ERR === $type) {
                 $output->writeln($messageService->red('----> ERROR START'));
                 $output->write($messageService->red('----> ' . $buffer));
                 $output->writeln($messageService->red('----> ERROR END'));
             } else {
                 $output->write($messageService->green($buffer));
             }
         });
     } else {
         $process->run();
     }
     return $process->getOutput();
 }
开发者ID:kryslin,项目名称:instance-manager,代码行数:36,代码来源:CommandService.php

示例6: __construct

 /**
  * Runner constructor.
  *
  * @param string $input
  * @param array $tokens
  * @param bool $script_source
  */
 public function __construct($input, array $tokens = [], $script_source = self::TEMPLATE_INPUT)
 {
     $this->process = new Process('');
     $this->process->setTimeout(null);
     if ($script_source === self::TEMPLATE_INPUT) {
         $this->script = with(new Parser())->parseFile($input, $tokens);
     } else {
         $this->script = with(new Parser())->parseString($input, $tokens);
     }
 }
开发者ID:rebelinblue,项目名称:deployer,代码行数:17,代码来源:Runner.php

示例7: process

 /**
  * @param $command
  * @throws ShellProcessFailed
  * @throws \Symfony\Component\Process\Exception\LogicException
  */
 public function process($command)
 {
     if (empty($command)) {
         return;
     }
     $this->process->setCommandLine($command);
     $this->process->setTimeout(null);
     $this->process->run();
     if (!$this->process->isSuccessful()) {
         throw new ShellProcessFailed($this->process->getErrorOutput());
     }
 }
开发者ID:alibo,项目名称:backup-manager,代码行数:17,代码来源:ShellProcessor.php

示例8: _reconfigure

 /**
  * {@inheritDoc}
  *
  * Starts the connection
  */
 public function _reconfigure($config = array())
 {
     parent::_reconfigure($config);
     if (!isset($this->config['username'])) {
         throw new \Exception("Sauce Connect Extension requires a username.");
     }
     if (!isset($this->config['accesskey'])) {
         throw new \Exception("Sauce Connect Extension requires a accesskey.");
     }
     $connect = __DIR__ . '/../../../bin/sauce_connect';
     if (!file_exists($connect)) {
         $connect = __DIR__ . '/../../../../bin/sauce_connect';
     }
     if (!file_exists($connect)) {
         throw new \Exception("Couldnt find the bin directory... Make sure its in ./bin or ./vendor/bin/");
     }
     $processBuilder = new ProcessBuilder([$connect]);
     $processBuilder->addEnvironmentVariables(['SAUCE_USERNAME' => $this->config['username'], 'SAUCE_ACCESS_KEY' => $this->config['accesskey']]);
     $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 60;
     $this->process = $processBuilder->getProcess();
     $this->process->setTimeout(0);
     $this->process->start(function ($type, $buffer) {
         $buffer = explode("\n", $buffer);
         foreach ($buffer as $line) {
             if (strpos($line, 'Press any key to see more output') === false) {
                 file_put_contents(codecept_output_dir() . 'sauce_connect.log', $line . "\n", FILE_APPEND);
             }
         }
     });
     $timer = 0;
     $connected = false;
     $this->writeln(["", "----------------------------------------------------------------------------", "Attempting to connect to SauceLabs. Waiting {$timeout} seconds."]);
     while ($this->process->isRunning() && $timer < $timeout) {
         $output = $this->process->getOutput();
         if (strpos($output, 'Connected! You may start your tests.') !== false) {
             $connected = true;
             break;
         }
         sleep(1);
         $timer++;
         if ($timer % 5 === 0) {
             $this->write('.');
         }
     }
     if (false === $connected) {
         $this->process->stop();
         throw new \Exception(sprintf("Could not start tunnel. Check %ssauce_connect.log for more information.", codecept_output_dir()));
     }
     $this->writeln(["", "Connected to SauceLabs", "----------------------------------------------------------------------------", ""]);
 }
开发者ID:lfgamers,项目名称:sauce-connect-extension,代码行数:55,代码来源:SauceConnectExtension.php

示例9: execute

 public function execute()
 {
     $logger = $this->getRunConfig()->getLogger();
     $this->process = new Process($this->command);
     $logger->info('Start command:' . $this->command);
     $this->process->setTimeout($this->timeout);
     $this->process->setWorkingDirectory($this->getRunConfig()->getRepositoryDirectory());
     $this->process->run();
     $output = trim($this->process->getOutput());
     $logger->info($output);
     if (!$this->process->isSuccessful()) {
         $logger->emergency($this->process->getErrorOutput());
         throw new \RuntimeException('Command not successful:' . $this->command);
     }
 }
开发者ID:funivan,项目名称:ci,代码行数:15,代码来源:ShellCommand.php

示例10: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configCommand = $this->getApplication()->find('oro:requirejs:generate-config');
     $configCommand->run(new ArrayInput(['command' => 'oro:requirejs:generate-config']), $output);
     $webRoot = $this->getContainer()->getParameter('oro_require_js.web_root');
     $config = $this->getContainer()->getParameter('oro_require_js');
     $configProvider = $this->getContainer()->get('oro_requirejs_config_provider');
     $output->writeln('Generating require.js build config');
     $buildConfigContent = $configProvider->generateBuildConfig(self::MAIN_CONFIG_FILE_NAME);
     $buildConfigContent = '(' . json_encode($buildConfigContent) . ')';
     $buildConfigFilePath = $webRoot . DIRECTORY_SEPARATOR . self::BUILD_CONFIG_FILE_NAME;
     if (false === @file_put_contents($buildConfigFilePath, $buildConfigContent)) {
         throw new \RuntimeException('Unable to write file ' . $buildConfigFilePath);
     }
     if (isset($config['js_engine']) && $config['js_engine']) {
         $output->writeln('Running code optimizer');
         $command = $config['js_engine'] . ' ' . self::OPTIMIZER_FILE_PATH . ' -o ' . basename($buildConfigFilePath) . ' 1>&2';
         $process = new Process($command, $webRoot);
         $process->setTimeout($config['building_timeout']);
         $process->run();
         if (!$process->isSuccessful()) {
             throw new \RuntimeException($process->getErrorOutput());
         }
         $output->writeln('Cleaning up');
         if (false === @unlink($buildConfigFilePath)) {
             throw new \RuntimeException('Unable to remove file ' . $buildConfigFilePath);
         }
         $output->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), realpath($webRoot . DIRECTORY_SEPARATOR . $config['build_path'])));
     }
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:33,代码来源:OroBuildCommand.php

示例11: download

 public function download($in_dir)
 {
     $repo = $in_dir . '/' . $this->package . ".git";
     if (is_dir($repo)) {
         return;
     }
     $cmd = 'git clone --mirror %s %s';
     $process = new Process(sprintf($cmd, $this->url, $repo));
     $process->setTimeout(3600);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \Exception($process->getErrorOutput());
     }
     $cmd = 'cd %s && git update-server-info -f';
     $process = new Process(sprintf($cmd, $repo));
     $process->setTimeout(3600);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \Exception($process->getErrorOutput());
     }
     $cmd = 'cd %s && git fsck';
     $process = new Process(sprintf($cmd, $repo));
     $process->setTimeout(3600);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \Exception($process->getErrorOutput());
     }
 }
开发者ID:matsinet,项目名称:medusa,代码行数:28,代码来源:Downloader.php

示例12: runCrons

 public function runCrons()
 {
     $entityManager = $this->managerRegistry->getManagerForClass('DspSoftsCronManagerBundle:CronTask');
     $cronTaskRepo = $entityManager->getRepository('DspSoftsCronManagerBundle:CronTask');
     $cronTasks = $cronTaskRepo->findCronsToLaunch();
     foreach ($cronTasks as $cronTask) {
         $run = true;
         if (!$cronTask->getRelaunch()) {
             $run = $this->planificationChecker->isExecutionDue($cronTask->getPlanification());
         }
         if ($run) {
             if ($this->logger !== null) {
                 $this->logger->info(sprintf('Running Cron Task <info>%s</info>', $cronTask->getName()));
             }
             $cli = 'exec ' . $this->kernelRootDir . DIRECTORY_SEPARATOR . 'console dsp:cron:runjob -c ' . $cronTask->getId() . ' &';
             if ($this->logger !== null) {
                 $this->logger->info(sprintf('Command line : <info>%s</info>', $cli));
             }
             $process = new Process($cli);
             $process->setTimeout(0);
             $process->start();
         } else {
             if ($this->logger !== null) {
                 $this->logger->info(sprintf('Skipping Cron Task <info>%s</info>', $cronTask->getName()));
             }
         }
     }
 }
开发者ID:dspsofts,项目名称:cronmanager-bundle,代码行数:28,代码来源:CronManipulator.php

示例13: start

 /**
  * Starts the server
  *
  * @param array $options
  * @return void
  */
 public function start(array $options)
 {
     $verbose = isset($options['verbose']) && $options['verbose'];
     if ($this->checkServer()) {
         $this->output->writeln("<error>Queue Manager is already running.</error>");
         return;
     }
     if ($verbose) {
         $this->output->writeln("<info>Queue Manager is starting.</info>");
     }
     $phpFinder = new PhpExecutableFinder();
     $phpPath = $phpFinder->find();
     if ($options['daemon']) {
         $command = $phpPath . ' app/console naroga:queue:start ' . ($verbose ? '-v' : '') . ' &';
         $app = new Process($command);
         $app->setTimeout(0);
         $app->start();
         $pid = $app->getPid();
         $this->memcache->replace('queue.lock', $pid);
         if ($verbose) {
             $this->output->writeln('<info>Queue Manager started with PID = ' . ($pid + 1) . '.</info>');
         }
         return;
     }
     $this->registerListeners($verbose);
     if ($verbose) {
         $pid = $this->memcache->get('queue.lock');
         $this->output->writeln('<info>Queue Manager started with PID = ' . $pid . '.</info>');
     }
     $this->resetServerConfig($options);
     $this->processQueue($options);
 }
开发者ID:naroga,项目名称:queue-manager,代码行数:38,代码来源:Manager.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $commandLine = $input->getArgument('command-line');
     if (!$this->tryParseChunkSize($input->getOption('chunk-size'), $chunkSize)) {
         $output->writeln('<error>Chunk size must be number optionally suffixed with k or M.</error>');
         return 1;
     }
     $model = $this->model;
     if ($id = $input->getOption('instance')) {
         if (!($entity = $model->getById($id))) {
             $output->writeln('<error>Rixxi\\Process\\Entities\\IProcess instance does not exist.</error>');
             return 1;
         }
     } else {
         $entity = $model->create($commandLine);
     }
     $process = new Process($commandLine);
     $process->setTimeout(NULL);
     $process->setIdleTimeout(NULL);
     $exitCode = $process->run(function ($type, $output) use($entity, $model, $chunkSize) {
         if (strlen($output) > $chunkSize) {
             $output = str_split($output, $chunkSize);
         } else {
             $output = array($output);
         }
         foreach ($output as $chunk) {
             $model->append($entity, $chunk, $type === Process::ERR);
         }
     });
     $model->finish($entity, $exitCode);
 }
开发者ID:rixxi,项目名称:watch-process,代码行数:31,代码来源:WatchCommand.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->downloadConfiguration();
     $library = new GLibc();
     try {
         $this->download()->extract();
         $library->setEnv($this->env)->setProjectDir($this->baseDir)->initialize()->boot($input, $output);
         $configure = $this->projectDir . '/' . $library->configure();
         $this->projectDir = dirname($this->projectDir) . '/glibc-build';
         $this->fs->mkdir($this->projectDir);
         $this->output->write('    Building   :  ');
         $process = new Process($configure, $this->projectDir, $this->env->toArray());
         $process->setTimeout(0);
         $process->run();
         if ($process->isSuccessful()) {
             $process->setCommandLine('make -j4 && make -j4 install');
             $process->run();
         }
         if ($process->isSuccessful()) {
             $message = '<info>✔</info>';
         } else {
             $message = '<error>✕</error>';
         }
         $this->output->writeln($message);
     } catch (\Exception $e) {
         $this->cleanUp();
         throw $e;
     }
     $this->createConfiguration();
     $this->output->writeln(sprintf(" <info>%s</info>  Droidphp Installer <info>successfully configured</info> Now you can:\n" . "    * Run :\n" . "        1. Execute the <comment>%s build:components</comment> command.\n" . " To Build the project\n\n", defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔', basename($_SERVER['PHP_SELF'])));
 }
开发者ID:mozanturhan,项目名称:droidphp-installer,代码行数:31,代码来源:SetupCommand.php


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