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


PHP Process::stop方法代码示例

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


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

示例1: foreach

 function check_job_servers()
 {
     //loop schemas
     foreach (Doo::db()->find('Schemata') as $s) {
         $schema_id = $s->id;
         //enabled config with PID
         foreach (Doo::db()->find('GearmanJobServers', array('where' => 'local = 1 AND enabled = 1 AND schema_id = ' . $schema_id)) as $js) {
             if (!empty($js->pid)) {
                 //init
                 $p = new Process();
                 $p->setPid($js->pid);
                 //check status
                 if ($p->status()) {
                     continue;
                 }
             }
             //let start
             $js->pid = $this->start_local_job_server($js->id, $js->port, $s->id);
             $js->update();
         }
         //disabled config
         foreach (Doo::db()->find('GearmanJobServers', array('where' => 'local = 1 AND enabled = 0 AND pid IS NOT NULL AND schema_id = ' . $schema_id)) as $js) {
             //stop
             $p = new Process();
             $p->setPid($js->pid);
             $p->stop();
             $js->pid = null;
             $js->update(array('setnulls' => true));
         }
     }
 }
开发者ID:garv347,项目名称:swanhart-tools,代码行数:31,代码来源:GearmanJobServerCLIController.php

示例2: 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;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:40,代码来源:ContextHelpers.php

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

示例4: testPublishKeyNameWithNamespaceAndRoomSet

 public function testPublishKeyNameWithNamespaceAndRoomSet()
 {
     $p = new Process('redis-cli monitor > redis.log');
     sleep(1);
     // Running this should produce something that's visible in `redis-cli monitor`
     $emitter = new Emitter(NULL, array('host' => '127.0.0.1', 'port' => '6379'));
     $emitter->of('/nsp')->to('rm')->emit('yolo', 'data');
     $p->stop();
     $contents = file_get_contents('redis.log');
     unlink('redis.log');
     $this->assertTrue(strpos($contents, 'socket.io#/nsp#rm#') !== FALSE);
 }
开发者ID:ashiina,项目名称:socket.io-php-emitter,代码行数:12,代码来源:test.php

示例5: foreach

 function check_workers()
 {
     //loop schemas
     foreach (Doo::db()->find('Schemata') as $s) {
         $schema_id = $s->id;
         $funcs = Doo::db()->fetchAll("SELECT a.id, a.schema_id, b.function_name, a.worker_count, a.enabled\r\n\t\t\t\tFROM gearman_functions a\r\n\t\t\t\tLEFT JOIN gearman_function_names b\r\n\t\t\t\tON a.function_name_id = b.id\r\n\t\t\t\tWHERE enabled = 1\r\n\t\t\t\tAND schema_id = {$schema_id}");
         //read worker config
         $worker_functions = array();
         foreach ($funcs as $f) {
             $worker_functions[$f["function_name"]] = $f["worker_count"];
         }
         //Loop enabled config
         foreach ($worker_functions as $function => $worker_count) {
             //find current workers for the function
             $runningWorkers = Doo::db()->find('GearmanWorkers', array('where' => "function_name = '{$function}' AND schema_id = {$schema_id}"));
             //scan workers to make sure they are still running
             foreach ($runningWorkers as $worker) {
                 //init
                 $p = new Process();
                 $p->setPid($worker->pid);
                 //check status
                 if (!$p->status()) {
                     //crashed! Lets re init
                     $gw = new GearmanWorkers();
                     $gw->pid = $this->start_worker($function, $schema_id);
                     $gw->function_name = $function;
                     $gw->schema_id = $schema_id;
                     $gw->insert();
                     //remove crashed pid
                     $worker->delete();
                 }
             }
             //calc delta workers
             $delta = $worker_count - count($runningWorkers);
             //add missing workers
             if ($delta > 0) {
                 for ($i = 0; $i < $delta; $i++) {
                     //run process
                     $sw = new GearmanWorkers();
                     $sw->pid = $this->start_worker($function, $schema_id);
                     $sw->function_name = $function;
                     $sw->schema_id = $schema_id;
                     $sw->insert();
                 }
             }
             //remove extra workers
             if ($delta < 0) {
                 //find current workers for the function
                 $runningWorkers = Doo::db()->find('GearmanWorkers', array('where' => "function_name = '{$function}' AND schema_id = {$schema_id}"));
                 for ($i = 0; $i < abs($delta); $i++) {
                     //kill process
                     $worker = $runningWorkers[$i];
                     $p = new Process();
                     $p->setPid($worker->pid);
                     $p->stop();
                     $worker->delete();
                 }
             }
         }
         //disabled config
         $funcs = Doo::db()->fetchAll("SELECT a.id, a.schema_id, b.function_name, a.worker_count, a.enabled\r\n\t\t\t\tFROM gearman_functions a\r\n\t\t\t\tLEFT JOIN gearman_function_names b\r\n\t\t\t\tON a.function_name_id = b.id\r\n\t\t\t\tWHERE enabled = 0\r\n\t\t\t\tAND schema_id = {$schema_id}");
         foreach ($funcs as $f) {
             $function = $f["function_name"];
             //find current workers for the function
             $disabledWorkers = Doo::db()->find('GearmanWorkers', array('where' => "function_name = '{$function}' AND schema_id = {$schema_id}"));
             //scan workers and kill to disable
             foreach ($disabledWorkers as $worker) {
                 //init
                 $p = new Process();
                 $p->setPid($worker->pid);
                 $p->stop();
                 $worker->delete();
             }
         }
     }
 }
开发者ID:garv347,项目名称:swanhart-tools,代码行数:76,代码来源:GearmanWorkerCLIController.php

示例6: stop

 public static function stop()
 {
     Process::stop('winvnc4');
     Process::stop('php');
 }
开发者ID:jacobwgillespie,项目名称:archive,代码行数:5,代码来源:service.class.php

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