本文整理汇总了PHP中setproctitle函数的典型用法代码示例。如果您正苦于以下问题:PHP setproctitle函数的具体用法?PHP setproctitle怎么用?PHP setproctitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setproctitle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: updateProcLine
/**
* On supported systems (with the PECL proctitle module installed), update
* the name of the currently running process to indicate the current state
* of a worker.
*
* @param string $status The updated process title.
*/
private function updateProcLine($status)
{
if (function_exists('setproctitle')) {
// setproctitle — 设置PHP进程的标题
setproctitle('resque-' . Resque::VERSION . ': ' . $status);
}
}
开发者ID:CraryPrimitiveMan,项目名称:php-resque-1.2-annotated,代码行数:14,代码来源:Worker.php
示例17: procline
public function procline($string)
{
if (function_exists('setproctitle')) {
setproctitle("resque-pool-manager{$this->appName}: {$string}");
}
}
开发者ID:babyun,项目名称:php-resque-pool,代码行数:6,代码来源:Logger.php
示例18: updateProcLine
/**
* Update the status of the current worker process.
*
* On supported systems (with the PECL proctitle module installed), update
* the name of the currently running process to indicate the current state
* of a worker.
*
* @param string $status The updated process title.
*/
private function updateProcLine($status)
{
if (function_exists('setproctitle')) {
setproctitle('resque-scheduler-' . ResqueRepeater::VERSION . ': ' . $status);
}
}
开发者ID:commonledger,项目名称:php-resque-repeater,代码行数:15,代码来源:Worker.php
示例19: doStart
/**
* process start
*/
protected function doStart()
{
if ($this->demonize) {
$pid = pcntl_fork();
if ($pid == -1) {
$this->halt(self::EXIT_CODE_ERROR, 'pcntl_fork() rise error');
} elseif ($pid) {
$this->halt(self::EXIT_CODE_NORMAL);
} else {
posix_setsid();
//close std streams (unlink console)
if (is_resource(STDIN)) {
fclose(STDIN);
$stdIn = fopen('/dev/null', 'r');
}
if (is_resource(STDOUT)) {
fclose(STDOUT);
$stdOut = fopen('/dev/null', 'ab');
}
if (is_resource(STDERR)) {
fclose(STDERR);
$stdErr = fopen('/dev/null', 'ab');
}
}
}
//rename process
if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
cli_set_process_title($this->getProcessName());
} else {
if (function_exists('setproctitle')) {
setproctitle($this->getProcessName());
} else {
throw new NotSupportedException("Can't find cli_set_process_title or setproctitle function");
}
}
//run iterator
return $this->loop();
}
开发者ID:aoyel,项目名称:yii2-daemon,代码行数:41,代码来源:DaemonController.php
示例20: cl_processtitle
function cl_processtitle($title)
{
$title = preg_replace('/[^\\w-]/', '', $title);
if (function_exists('cli_set_process_title')) {
// PHP5.5 and up
cli_set_process_title('phpList:' . $GLOBALS['installation_name'] . ':' . $title);
} elseif (function_exists('setproctitle')) {
// pecl extension
setproctitle('phpList:' . $GLOBALS['installation_name'] . ':' . $title);
}
}
开发者ID:gillima,项目名称:phplist3,代码行数:11,代码来源:connect.php
注:本文中的setproctitle函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论