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


PHP Process::getPid方法代码示例

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


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

示例1: 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()]);
     }
 }
开发者ID:asuper114,项目名称:simple-fork-php,代码行数:21,代码来源:ParallelPool.php

示例2: ensureRunning

 public static function ensureRunning($cmd, $pidfile, $restart = false)
 {
     $pidfile = '/var/run/' . $pidfile;
     // get pid from pidfile, protecting against invalid data
     $p1 = null;
     if (file_exists($pidfile) && is_readable($pidfile)) {
         $pid = substr(file_get_contents($pidfile), 0, 64);
         $p1 = new Process();
         $p1->setPid($pid);
     }
     if ($restart && $p1) {
         $p1->stop();
     }
     // check whether process with this pid is running
     if (!$p1 || !$p1->status()) {
         // check that we can write the pidfile, to avoid spawning endless processes
         if (file_put_contents($pidfile, 'test')) {
             $p2 = new Process($cmd);
             file_put_contents($pidfile, $p2->getPid());
         }
         return true;
     }
     return false;
 }
开发者ID:Geekathon,项目名称:Selective-Tweets,代码行数:24,代码来源:Process.php

示例3: checkPidFile

 function checkPidFile($pidfile = null)
 {
     if ($pidfile == null) {
         if ($this->_pidfile) {
             $pidfile = $this->_pidfile;
         } else {
             $pidfile = $this->getName() . '.pid';
         }
     }
     logger::debug('Checking pidfile: %s', $pidfile);
     // Check if the process exist
     if (file_exists($pidfile)) {
         $pid = file_get_contents($pidfile);
         $p = new Process($pid);
         logger::debug(' - Inspecting pid %d', $pid);
         if ($p->exists()) {
             // Already running
             return self::PROCESS_RUNNING;
         }
         unlink($pidfile);
         $retval = self::PROCESS_STALE;
     } else {
         $retval = self::PROCESS_CLEAR;
     }
     $tp = new Process();
     file_put_contents($pidfile, $tp->getPid());
     $this->_pidfile = $pidfile;
     return $retval;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:29,代码来源:application.php

示例4: crawler_exec

 private function crawler_exec($keywords, $initial_date, $final_date)
 {
     $crawler_dir = Configure::read('Crawler.path');
     $scrapy_path = Configure::read('Crawler.scrapy.path');
     $crawler_name = "folha-spider";
     $command = "cd {$crawler_dir} ; {$scrapy_path} crawl {$crawler_name} " . " -a keywords={$keywords} " . " -a initial_date={$initial_date} " . " -a final_date={$final_date}";
     $this->log("Runing crawler with command {$command}", 'debug');
     $process = new Process($command);
     return $process->getPid();
 }
开发者ID:pcalcina,项目名称:news-analyser,代码行数:10,代码来源:NewsController.php

示例5: 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);
     // }
 }
开发者ID:shaogx,项目名称:easyJob,代码行数:36,代码来源:Worker.php

示例6: delete

 /**
  * @param Process $process
  * @return void
  */
 public function delete(Process $process)
 {
     unset($this->processes[$process->getPid()]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:ProcessManager.php

示例7: 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;
         }
     }
 }
开发者ID:huyanping,项目名称:simple-fork-php,代码行数:16,代码来源:ParallelPool.php

示例8: start_worker

 private function start_worker($function, $schema_id)
 {
     $cmd = "php cli.php worker {$schema_id} {$function} > protected/log/gearman_worker.{$schema_id}.{$function}.log 2>&1";
     $p = new Process($cmd);
     return $p->getPid();
 }
开发者ID:garv347,项目名称:swanhart-tools,代码行数:6,代码来源:GearmanWorkerCLIController.php

示例9: setCurrentProcess

 /**
  * Set the current process.
  * 
  * @param Process $proc the process to set as current,  the attribute <b>pid</b> should be filled with the process pid.
  * @throws EyeInvalidArgumentException If the arguments are incorrect
  * @throws EyeProcException If there is no such process with the given pid
  */
 public function setCurrentProcess(Process $proc = null)
 {
     if ($proc !== null) {
         $processTable = $this->getProcessesTable();
         $pid = $proc->getPid();
         if (!isset($processTable[$pid])) {
             throw new EyeProcException('Process $proc with PID ' . $pid . ' not found.');
         }
     }
     $this->currentProcess = $proc;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:18,代码来源:ProcManager.php

示例10: stop

function stop()
{
    //stop function
    global $conf;
    global $db;
    $result = $db->query("SELECT count(*) AS C FROM pid");
    $row = $result->fetchArray();
    // output data of each row
    $result = $db->query("SELECT * FROM pid LIMIT 1");
    $row = $result->fetchArray();
    $process = new Process();
    $process->setPid($row["pid"]);
    if (!$process->status()) {
        $sql = "DELETE FROM pid";
        $result = $db->query($sql);
        $return_array["info"] = "process already dead";
    } else {
        $response_array["pid"] = $process->getPid();
        $process->stop();
        $sql = "DELETE FROM pid";
        $result = $db->query($sql);
        $return_array["info"] = "process stopped";
    }
    sleep(1);
    cleanpl();
    $return_array["status"] = 0;
    return $return_array;
}
开发者ID:holg,项目名称:E2Transcoder,代码行数:28,代码来源:control.php


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