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


PHP Process::getPid方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $procApp = $input->getArgument('procApp');
     $procCall = $input->getArgument('procCall');
     $procArgs = $input->getArgument('processArgs');
     $cmd = 'php ' . $procApp . ' ' . $procCall . ' ' . implode(' ', $procArgs);
     $process = new Process($cmd);
     $process->start();
     echo 'PID: ' . $process->getPid() . "\n";
 }
开发者ID:ricma985,项目名称:symfony3,代码行数:10,代码来源:BacgrounderCommand.php

示例2: 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

示例3: startProcess

 /**
  * Starts a process in the background - waits for 1 second to check that the process did not die prematurely
  * (it is supposed to be a long-running task)
  * @param string $command
  *
  * @return int the pid of the created process
  * @throws \Symfony\Component\Process\Exception\RuntimeException when process could not start / terminated immediately
  */
 public function startProcess($command)
 {
     $process = new Process($command);
     $process->start();
     // give the OS some time to abort invalid commands
     sleep(1);
     if (!$process->isRunning()) {
         throw new RuntimeException("Process terminated immediately");
     }
     // while at it, emit a message
     if ($this->dispatcher) {
         $event = new ProcessStartedEvent($process->getPid(), $command);
         $this->dispatcher->dispatch(EventsList::PROCESS_STARTED, $event);
     }
     return $process->getPid();
 }
开发者ID:bazitov,项目名称:kueueingbundle,代码行数:24,代码来源:Watchdog.php

示例4: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return bool
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $process = new Process($input->getArgument('argument'));
     $process->start();
     $pid = $process->getPid();
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $entity_process = new \Monotype\Bundle\DirectControllBundle\Entity\Process();
     $entity_process->setPid($process->getPid());
     $entity_process->setScript($input->getArgument('argument'));
     $entity_process->setUid('manual');
     $entity_process->setDatetime(new \DateTime('now'));
     $entityManager->persist($entity_process);
     $entityManager->flush();
     $output->writeln('Command "' . $input->getArgument('argument') . '" result:');
     $output->writeln('PID: ' . $pid . PHP_EOL);
     return true;
 }
开发者ID:jetalone,项目名称:monotype,代码行数:22,代码来源:ProcessStartCommand.php

示例5: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return bool
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $process = new Process('watch df -h');
     $process->start();
     $pid = $process->getPid();
     $output->writeln('Command result:');
     $output->writeln('PID: ' . $pid . PHP_EOL);
     return true;
 }
开发者ID:jetalone,项目名称:monotype,代码行数:14,代码来源:ProcessTestCommand.php

示例6: newWorker

 public function newWorker()
 {
     $queue = Input::get('queue');
     $root = base_path();
     $cmd = 'php artisan worker:start ' . $queue;
     $p = new Symfony\Component\Process\Process($cmd, $root);
     $p->start();
     return Response::json(array('res' => 0, 'pid' => $p->getPid()));
 }
开发者ID:kangzhenkang,项目名称:eleme-deploy,代码行数:9,代码来源:JobController.php

示例7: start_proc

 protected function start_proc(&$entry)
 {
     $process = new Process($entry["command"], $this->cwd, $this->env);
     $process->start();
     $entry["pid"] = $process->getPid();
     $entry["process"] = $process;
     if (empty($entry["pid"])) {
         throw new \Exception($entry["name"] . " could not be run");
     }
 }
开发者ID:oripekelman,项目名称:phoreman,代码行数:10,代码来源:Procfile.php

示例8: run

 /**
  * {@inheritdoc}
  */
 public function run(JobReportInterface $report)
 {
     try {
         $this->process->start();
         $this->savePid($this->process->getPid(), $report);
         while ($this->process->isRunning()) {
             // waiting for process to finish
         }
         if ($this->process->isSuccessful()) {
             $report->setOutput(trim($this->process->getOutput()));
             return JobState::STATE_FINISHED;
         }
         $report->setErrorOutput(trim($this->process->getErrorOutput()));
     } catch (LogicException $e) {
         $report->setErrorOutput($e->getMessage());
     } catch (RuntimeException $e) {
         $report->setErrorOutput($e->getMessage());
     }
     return JobState::STATE_FAILED;
 }
开发者ID:dpk125,项目名称:JobQueue,代码行数:23,代码来源:ShellJob.php

示例9: runChildProcess

 /**
  * Run child process.
  *
  * @param Daemonize $daemon
  *
  * @return mixed
  */
 public function runChildProcess(Daemonize $daemon)
 {
     $this->output->setEnableAnsi(false);
     $this->output->setStdOut($this->log);
     $this->output->setStdErr($this->log);
     $this->process->start();
     if (!$this->process->isRunning()) {
         throw new RuntimeException('Unable to start server process.');
     }
     $this->processControl->setPid($this->process->getPid());
     $this->process->wait(function ($type, $buffer) {
         $this->output->writeln($buffer);
     });
 }
开发者ID:borobudur-php,项目名称:framework-bundle,代码行数:21,代码来源:ServerStartConsole.php

示例10: startProcess

 /**
  * @param Process $process
  * @param string $pidFile
  * @param OutputInterface $log
  *
  * @throws \Exception on failure
  *
  * @return int
  *   The process PID.
  */
 public function startProcess(Process $process, $pidFile, OutputInterface $log)
 {
     $this->processes[$pidFile] = $process;
     try {
         $process->start(function ($type, $buffer) use($log) {
             $log->writeln($buffer);
         });
     } catch (\Exception $e) {
         unset($this->processes[$pidFile]);
         throw $e;
     }
     $pid = $process->getPid();
     if (file_put_contents($pidFile, $pid) === false) {
         throw new \RuntimeException('Failed to write PID file: ' . $pidFile);
     }
     $log->writeln(sprintf('Process started: %s', $process->getCommandLine()));
     return $pid;
 }
开发者ID:drewmelck,项目名称:platformsh-cli,代码行数:28,代码来源:ProcessManager.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $startTime = microtime(true);
     $tables = $this->getContainer()->getParameter('tables');
     $limit = (int) $input->getOption('limit');
     $commands = [];
     foreach (array_keys($tables['root']) as $root) {
         $commands[] = "kp:scrap:page {$root}";
     }
     foreach ($tables['child'] as $root => $tables) {
         foreach (array_keys($tables) as $child) {
             $commands[] = "kp:scrap:sub:page {$root} {$child}";
         }
     }
     /* @var $processes Process[] */
     $processes = [];
     foreach ($commands as $command) {
         $processes[$command] = $process = new Process("app/console {$command} --limit={$limit}");
         $output->writeln("start: <info>{$command}</info>");
         $process->start();
     }
     while (true) {
         foreach ($processes as $command => $process) {
             if ($process->isRunning()) {
                 $output->writeln("Running {$command}: <info>{$process->getPid()}</info>");
             } else {
                 $output->writeln("Finish <info>{$command}</info>:");
                 $output->writeln($process->getOutput());
                 $processes[$command] = $process->restart();
             }
             sleep(1);
         }
         $duration = microtime(true) - $startTime;
         $output->writeln("<info>Time: {$duration}</info>");
     }
 }
开发者ID:VERGOUA,项目名称:KPars,代码行数:36,代码来源:ComplexCommand.php

示例12: runCommand

 private function runCommand($string, $timeout = 0)
 {
     $entityManager = $this->managerRegistry->getManagerForClass('DspSoftsCronManagerBundle:CronTaskLog');
     try {
         $process = new Process($string);
         $process->setTimeout($timeout);
         $process->start(array($this, 'callbackProcess'));
         $this->cronTaskLog->setPid($process->getPid());
         $entityManager->persist($this->cronTaskLog);
         $entityManager->flush();
         $exitCode = $process->wait();
         $this->cronTaskLog->setDateEnd(new \DateTime());
         if ($exitCode > 0) {
             $this->cronTaskLog->setStatus(CronTaskLog::STATUS_FAILED);
         } elseif ($process->getErrorOutput() != '') {
             $this->cronTaskLog->setStatus(CronTaskLog::STATUS_WARNING);
         } else {
             $this->cronTaskLog->setStatus(CronTaskLog::STATUS_SUCCESS);
         }
         $this->cronTaskLog->setPid(null);
         $entityManager->persist($this->cronTaskLog);
         $entityManager->flush();
         return $exitCode !== 0;
     } catch (\Exception $e) {
         $this->cronTaskLog->setStatus(CronTaskLog::STATUS_FAILED);
         $this->cronTaskLog->setPid(null);
         $this->cronTaskLog->setDateEnd(new \DateTime());
         $entityManager->persist($this->cronTaskLog);
         $entityManager->flush();
         return 1;
     }
 }
开发者ID:dspsofts,项目名称:cronmanager-bundle,代码行数:32,代码来源:JobRunner.php

示例13: lock

 /**
  * Lock the event
  *
  * @param  \Crunz\Event $event
  *
  * @return string
  */
 protected function lock()
 {
     file_put_contents($this->lockFile(), $this->process->getPid());
 }
开发者ID:lavary,项目名称:crunz,代码行数:11,代码来源:Event.php

示例14: runProcessAsync

 /**
  * @param $command
  * @param bool $isRestore
  */
 protected function runProcessAsync($command, $isRestore = false)
 {
     $process = new Process($command);
     $process->start();
     $pid = $process->getPid();
     $activePids = Yii::$app->session->get('backupPids', []);
     if (!$process->isRunning()) {
         if ($process->isSuccessful()) {
             $msg = !$isRestore ? Yii::t('dbManager', 'Dump successfully created.') : Yii::t('dbManager', 'Dump successfully restored.');
             Yii::$app->session->addFlash('success', $msg);
         } else {
             $msg = !$isRestore ? Yii::t('dbManager', 'Dump failed.') : Yii::t('dbManager', 'Restore failed.');
             Yii::$app->session->addFlash('error', $msg . '<br>' . 'Command - ' . $command . '<br>' . $process->getOutput() . $process->getErrorOutput());
             Yii::error($msg . PHP_EOL . 'Command - ' . $command . PHP_EOL . $process->getOutput() . PHP_EOL . $process->getErrorOutput());
         }
     } else {
         $activePids[$pid] = $command;
         Yii::$app->session->set('backupPids', $activePids);
         Yii::$app->session->addFlash('info', Yii::t('dbManager', 'Process running with pid={pid}', ['pid' => $pid]) . '<br>' . $command);
     }
 }
开发者ID:beaten-sect0r,项目名称:yii2-db-manager,代码行数:25,代码来源:DefaultController.php

示例15: startDisplayProcess

 public function startDisplayProcess()
 {
     if ($this->isWindows()) {
         $cmd = null;
     } else {
         if ($this->getEnvVar('DISPLAY')) {
             return true;
         }
         $this->setEnvVar('DISPLAY', ':99.0');
         $cmd = '/sbin/start-stop-daemon --start --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16';
     }
     $output = new BufferedOutput();
     $process = new Process($cmd, SeleniumSetup::$APP_ROOT_PATH, SeleniumSetup::$APP_PROCESS_ENV, null, null);
     $process->run(function ($type, $line) use($output) {
         $output->write($line);
     });
     //var_dump($process->getPid());
     return $process->getPid();
 }
开发者ID:bogdananton,项目名称:selenium-setup,代码行数:19,代码来源:Environment.php


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