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


PHP setproctitle函数代码示例

本文整理汇总了PHP中setproctitle函数的典型用法代码示例。如果您正苦于以下问题:PHP setproctitle函数的具体用法?PHP setproctitle怎么用?PHP setproctitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: launchJob

 protected function launchJob($jobID)
 {
     if (FALSE === $this->fire('onLauncher', array(&$this))) {
         usleep(20000);
         return false;
     }
     $pid = pcntl_fork();
     if ($pid == -1) {
         $this->fire('onLaunchJobError', array(&$this));
         return false;
     } else {
         if ($pid) {
             $this->currentObjects[$pid] = $this->childObject;
             $this->currentJobs[$pid] = $jobID;
             if (isset($this->signalQueue[$pid])) {
                 $this->childSignalHandler(SIGCHLD, $pid, $this->signalQueue[$pid]);
                 unset($this->signalQueue[$pid]);
             }
         } else {
             unset($this->currentObjects);
             $exitStatus = 0;
             setproctitle($this->childsProcName);
             $this->fire('onLaunchJob', array(&$this));
             exit($exitStatus);
         }
     }
     return true;
 }
开发者ID:rauljrz,项目名称:php-daemon-1,代码行数:28,代码来源:class.daemon.php

示例2: changeProcessTitleTo

 private static function changeProcessTitleTo($processTitle)
 {
     if (function_exists('cli_set_process_title')) {
         cli_set_process_title($processTitle);
     } elseif (function_exists('setproctitle')) {
         setproctitle($processTitle);
     }
 }
开发者ID:webmozart,项目名称:console,代码行数:8,代码来源:ProcessTitle.php

示例3: setProcessName

 /**
  * 设置进程名称
  *
  * @param $title
  */
 protected static function setProcessName($title)
 {
     $title = "php_daemon_{$title}";
     if (function_exists('cli_set_process_title')) {
         cli_set_process_title($title);
     } elseif (extension_loaded('proctitle') && function_exists('setproctitle')) {
         setproctitle($title);
     }
 }
开发者ID:phpdn,项目名称:framework,代码行数:14,代码来源:ProcessManage.php

示例4: _init

 protected function _init()
 {
     setproctitle('Daemon: QueueManager');
     $this->_initSockets();
     $this->_initFactories();
     $this->_processingLoop();
     $this->_shutdownProcessingLoop();
     exit;
 }
开发者ID:sgraebner,项目名称:tp,代码行数:9,代码来源:QueueManager.php

示例5: _init

 protected function _init()
 {
     setproctitle('Daemon: downloader');
     $this->_initSockets();
     $this->_getDownloadListFromWorker();
     $this->_checkAndFilterDownloads();
     $this->_startDownloads();
     exit;
 }
开发者ID:sgraebner,项目名称:tp,代码行数:9,代码来源:Downloader.php

示例6: _init

 protected function _init()
 {
     $this->_identity = 'worker/' . uniqid();
     setproctitle(sprintf('Daemon: %s', $this->_identity));
     $this->_initSocket();
     $this->_registerAtQueueManager();
     register_shutdown_function(array($this, 'shutdown'));
     $this->_processingLoop();
 }
开发者ID:sgraebner,项目名称:tp,代码行数:9,代码来源:Worker.php

示例7: wfProfileOut

 function wfProfileOut($fn = '')
 {
     global $hackwhere, $wgDBname;
     if (count($hackwhere)) {
         array_pop($hackwhere);
     }
     if (function_exists("setproctitle") && count($hackwhere)) {
         setproctitle($hackwhere[count($hackwhere) - 1] . " [{$wgDBname}]");
     }
 }
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:10,代码来源:Setup.php

示例8: setTitle

 /**
  * 设置进程名
  * @param [type] $title [description]
  */
 public static function setTitle($title)
 {
     if (function_exists('cli_set_process_title')) {
         // PHP >= 5.5
         cli_set_process_title($title);
     } else {
         if (function_exists('setproctitle')) {
             // PECL proctitle >= 0.1.0
             setproctitle($title);
         }
     }
 }
开发者ID:hitzheng,项目名称:ares,代码行数:16,代码来源:proc.php

示例9: setProcessTitle

 /**
  * Sets the process title.
  *
  * @param string $title
  */
 public function setProcessTitle($title)
 {
     if (function_exists('cli_set_process_title')) {
         cli_set_process_title($title);
         //PHP >= 5.5.
     } else {
         if (function_exists('setproctitle')) {
             setproctitle($title);
             //PECL proctitle
         }
     }
 }
开发者ID:meckhardt,项目名称:ko-process,代码行数:17,代码来源:ProcessTitle.php

示例10: setTitle

 public static function setTitle($title)
 {
     $ret = true;
     if (function_exists('cli_set_process_title') && PHP_OS != 'Darwin') {
         cli_set_process_title($title);
     } elseif (function_exists('setproctitle')) {
         setproctitle($title);
     } else {
         $ret = false;
     }
     return $ret;
 }
开发者ID:wedgwood,项目名称:serverbench.php,代码行数:12,代码来源:Util.php

示例11: wfProfileOut

/**
 * Stop profiling of a function
 * @param $fn string
 */
function wfProfileOut($fn = '')
{
    global $hackwhere, $wgDBname, $haveProctitle;
    if (!$haveProctitle) {
        return;
    }
    if (count($hackwhere)) {
        array_pop($hackwhere);
    }
    if (count($hackwhere)) {
        setproctitle($hackwhere[count($hackwhere) - 1] . " [{$wgDBname}]");
    }
}
开发者ID:GodelDesign,项目名称:Godel,代码行数:17,代码来源:ProfilerStub.php

示例12: _init

 protected function _init()
 {
     $pid = pcntl_fork();
     if ($pid !== 0) {
         return;
     }
     $pidFile = $this->_config->get('pid_file');
     if (file_exists($pidFile) && '' != exec('ps -p `cat ' . $pidFile . '` --no-heading')) {
         trigger_error('Process running with PID ' . file_get_contents($pidFile), E_USER_NOTICE);
         exit(0);
     }
     file_put_contents($pidFile, getmypid());
     setproctitle('Daemon: ForkMaster');
     $this->_forkChilds();
     $this->_monitorChildProcesses();
 }
开发者ID:sgraebner,项目名称:tp,代码行数:16,代码来源:ForkMaster.php

示例13: run

 /**
  * Run the execution loop.
  *
  * Forks into a master and a loop process. The loop process will handle the
  * evaluation of all instructions, then return its state via a socket upon
  * completion.
  *
  * @param Shell $shell
  */
 public function run(Shell $shell)
 {
     list($up, $down) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
     if (!$up) {
         throw new \RuntimeException('Unable to create socket pair.');
     }
     $pid = pcntl_fork();
     if ($pid < 0) {
         throw new \RuntimeException('Unable to start execution loop.');
     } elseif ($pid > 0) {
         // This is the main thread. We'll just wait for a while.
         // We won't be needing this one.
         fclose($up);
         // Wait for a return value from the loop process.
         $read = array($down);
         $write = null;
         $except = null;
         if (stream_select($read, $write, $except, null) === false) {
             throw new \RuntimeException('Error waiting for execution loop.');
         }
         $content = stream_get_contents($down);
         fclose($down);
         if ($content) {
             $shell->setScopeVariables(@unserialize($content));
         }
         return;
     }
     // This is the child process. It's going to do all the work.
     if (function_exists('setproctitle')) {
         setproctitle('psysh (loop)');
     }
     // We won't be needing this one.
     fclose($down);
     // Let's do some processing.
     parent::run($shell);
     // Send the scope variables back up to the main thread
     fwrite($up, $this->serializeReturn($shell->getScopeVariables()));
     fclose($up);
     exit;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:49,代码来源:ForkingLoop.php

示例14: setProcessTitle

 /**
  * Sets the proccess title
  *
  * This function call requires php5.5+ or the proctitle extension!
  * Empty title strings won't be set.
  * @param string $title the new process title
  * @param array $replacements an associative array of replacment values
  * @return void
  */
 public static function setProcessTitle($title, array $replacements = array())
 {
     // skip when empty title names or running on MacOS
     if (trim($title) == '' || PHP_OS == 'Darwin') {
         return;
     }
     // 1. replace the values
     $title = preg_replace_callback('/\\%([a-z0-9]+)\\%/i', function ($match) use($replacements) {
         if (isset($replacements[$match[1]])) {
             return $replacements[$match[1]];
         }
         return $match[0];
     }, $title);
     // 2. remove forbidden chars
     $title = preg_replace('/[^a-z0-9-_.: \\\\\\]\\[]/i', '', $title);
     // 3. set the title
     if (function_exists('cli_set_process_title')) {
         cli_set_process_title($title);
         // PHP 5.5+ has a builtin function
     } elseif (function_exists('setproctitle')) {
         setproctitle($title);
         // pecl proctitle extension
     }
 }
开发者ID:KevenLibcast,项目名称:WorkerPool,代码行数:33,代码来源:ProcessDetails.php

示例15: renameProcess

 /**
  * Rename process name
  *
  * @param string $prefix Prefix for the process name
  * @throws NotSupportedException
  */
 protected function renameProcess($prefix = '')
 {
     $name = $this->getProcessName();
     if (false === empty($prefix)) {
         $name = $prefix . '-' . $name;
     }
     //rename process
     if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
         cli_set_process_title($name);
     } else {
         if (function_exists('setproctitle')) {
             setproctitle($name);
         } else {
             throw new NotSupportedException("Can't find cli_set_process_title or setproctitle function");
         }
     }
 }
开发者ID:phantom-d,项目名称:yii2-file-daemon,代码行数:23,代码来源:DaemonController.php


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