本文整理汇总了PHP中Process::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::start方法的具体用法?PHP Process::start怎么用?PHP Process::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
* Asynchronously start mediainfo operation.
* Make call to MediaInfoCommandRunner::wait() afterwards to receive output.
*/
public function start()
{
$this->processBuilder->add($this->filePath);
$this->processAsync = $this->processBuilder->getProcess();
// just takes advantage of symfony's underlying Process framework
// process runs in background
$this->processAsync->start();
}
示例2: execute
/**
* add a process
*
* @param Process $process
* @param null|string $name process name
* @return int
*/
public function execute(Process $process, $name = null)
{
if (!is_null($name)) {
$process->name($name);
}
$process->start();
return array_push($this->processes, $process);
}
示例3: start
/**
* {@inheritdoc}
*/
public function start($callback = null)
{
if (null === $this->getCommandLine()) {
if (false === ($php = $this->executableFinder->find())) {
throw new \RuntimeException('Unable to find the PHP executable.');
}
$this->setCommandLine($php);
}
parent::start($callback);
}
示例4: tick
/**
* start new processes if needed
*
* @return int num of job
*/
public function tick()
{
if ($this->countPool() < 1 && $this->countJob()) {
$job = $this->getJob();
if ($job) {
$szal = new Process($this->worker);
$szal->setLifeTime(4);
//NOTICE
$this->pool[] = $szal;
$szal->start($job);
}
}
return $this->countJob();
}
示例5: reload
/**
* start the same number processes and kill the old sub process
* just like nginx -s reload
* this method will block until all the old process exit;
*
* @param bool $block
*/
public function reload($block = true)
{
$old_process = $this->processes;
for ($i = 0; $i < $this->max; $i++) {
$process = new Process($this->runnable);
$process->start();
$this->processes[$process->getPid()] = $process;
}
foreach ($old_process as $process) {
$process->shutdown();
$process->wait($block);
unset($this->processes[$process->getPid()]);
}
}
示例6: startBudabot
/**
* Starts Budabot instance.
* Calling this more than once has no effect unless the bot is not running.
*/
public static function startBudabot()
{
if (self::$botProcess) {
return;
}
// delete old DB-file if it exists
@unlink(ROOT_PATH . '/data/' . self::$vars['DB Name']);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$phpExec = realpath(ROOT_PATH . "\\win32\\php.exe") . " -c php-win.ini";
} else {
$phpExec = "php";
}
// start budabot instance
$process = new Process();
$process->setCommand("{$phpExec} -f tests/helpers/test_main.php");
$path = self::$parameters['budabot_log'];
if (is_string($path)) {
$file = fopen($path, 'w');
$process->setDescriptorspec(array(1 => $file, 2 => $file));
} else {
if ($path) {
$process->setDescriptorspec(array());
} else {
$process->setDescriptorspec(array(1 => array('file', 'nul', 'w'), 2 => array('file', 'nul', 'w')));
}
}
$process->setWorkingDir(ROOT_PATH);
if (!$process->start()) {
throw new Exception("Failed to start Budabot!");
}
// make sure that the bot instance is terminated on exit
register_shutdown_function(function () use($process) {
$process->stop();
});
self::$botProcess = $process;
}
示例7: spawn
/**
* fork process with job
*
* @return
*/
public function spawn()
{
$worker = $this->ready();
$ident = $this->getIdent($worker);
//use Process
$p = new Process($worker);
$p->start();
$pid = $p->getPid();
if ($pid) {
$this->childPool[$ident][$pid] = $pid;
}
// //@TODO
// $pid = pcntl_fork();
// if ($pid == -1) {
// } elseif ($pid) {
// $this->childPool[$ident][$pid] = $pid;
// } else {
// //@TODO
// //$this->setOwner($name = 'www');
// //$this->setTitle($title);
// $this->childPool[$ident] = [];
// //$cid = getmypid();
// //echo "\ngetmypid={$cid}\n";
// // 这个符号表示恢复系统对信号的默认处理
// pcntl_signal(SIGTERM, SIG_DFL);
// pcntl_signal(SIGCHLD, SIG_DFL);
// call_user_func_array($worker, array());
// //call_user_func_array($worker);
// exit(0);
// }
}
示例8: start
/**
* start the pool
*/
public function start()
{
$alive_count = $this->aliveCount();
// create sub process and run
if ($alive_count < $this->max) {
$need = $this->max - $alive_count;
for ($i = 0; $i < $need; $i++) {
$process = new Process($this->runnable);
$process->start();
$this->processes[$process->getPid()] = $process;
}
}
}
示例9: __construct
public $counter;
public function __construct()
{
$this->counter = 0;
}
public function run()
{
}
}
class Process extends Worker
{
private $text = "";
public function __construct($text, $object)
{
$this->text = $text;
$this->object = $object;
}
public function run()
{
while ($this->object->counter < 10) {
print $this->object->counter++ . " - {$this->text}\n";
sleep(1);
}
}
}
$foo = new Foo();
$a = new Process("A", $foo);
$a->start();
$b = new Process("B", $foo);
$b->start();
示例10: generate_password
public static function generate_password()
{
global $vncpwd;
Process::start('php', $vncpwd, false);
}