本文整理汇总了PHP中swoole_set_process_name函数的典型用法代码示例。如果您正苦于以下问题:PHP swoole_set_process_name函数的具体用法?PHP swoole_set_process_name怎么用?PHP swoole_set_process_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了swoole_set_process_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: my_onStart
function my_onStart(swoole_server $serv)
{
global $argv;
swoole_set_process_name("php {$argv[0]}: master");
echo "MasterPid={$serv->master_pid}|Manager_pid={$serv->manager_pid}\n";
echo "Server: start.Swoole version is [" . SWOOLE_VERSION . "]\n";
}
示例2: set_process_name
/**
* 设置进程名
*/
private static function set_process_name()
{
if (!function_exists("swoole_set_process_name")) {
self::exit2p("Please install swoole extension.http://www.swoole.com/");
}
swoole_set_process_name(self::$process_name);
}
示例3: run
public static function run($fd)
{
self::$fp = fopen("php://fd/" . $fd, "a");
swoole_set_process_name(self::$name);
self::http_server();
self::start();
}
示例4: start
protected function start()
{
if ($this->pidManager->get()) {
echo "ERROR: plumber is already running.\n";
return;
}
echo "plumber started.\n";
if ($this->config['daemonize']) {
swoole_process::daemon();
}
$this->logger = new Logger(['log_path' => $this->config['log_path']]);
$this->output = new Logger(['log_path' => $this->config['output_path']]);
$this->logger->info('plumber starting...');
$this->stats = $stats = $this->createListenerStats();
swoole_set_process_name('plumber: master');
$this->workers = $this->createWorkers($stats);
$this->registerSignal();
$this->pidManager->save(posix_getpid());
swoole_timer_tick(1000, function ($timerId) {
$statses = $this->stats->getAll();
foreach ($statses as $pid => $s) {
if ($s['last_update'] + $this->config['reserve_timeout'] + $this->config['execute_timeout'] > time()) {
continue;
}
if (!$s['timeout']) {
$this->logger->notice("process #{$pid} last upadte at " . date('Y-m-d H:i:s') . ', it is timeout.', $s);
$this->stats->timeout($pid);
}
}
});
}
示例5: my_set_process_name
private function my_set_process_name($title)
{
if (substr(PHP_VERSION, 0, 3) >= '5.5') {
cli_set_process_title($title);
} else {
swoole_set_process_name($title);
}
}
示例6: onStart
public function onStart()
{
swoole_set_process_name(SWOOLE_DEAMON);
$reload = "echo 'Reloading...'\n";
$reload .= "pid=\$(pidof " . SWOOLE_DEAMON . ")\n";
$reload .= "kill -USR1 \"\$pid\"\n";
$reload .= "echo 'Reloaded'\n";
file_put_contents(__DIR__ . '/reload_' . SWOOLE_DEAMON . '.sh', $reload);
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$operation = $input->getArgument('operation');
swoole_set_process_name("kerisy-rpcserver:manage");
if (!in_array($operation, ['run', "stop", "start", "restart"])) {
throw new InvalidParamException('The <operation> argument is invalid');
}
return call_user_func([$this, 'handle' . $operation]);
}
示例8: onWorkerStart
public function onWorkerStart($server, $worker_id)
{
global $argv;
if ($worker_id >= $server->setting['worker_num']) {
swoole_set_process_name("php {$argv[0]} task worker");
} else {
swoole_set_process_name("php {$argv[0]} event worker");
}
echo "WorkerStart|MasterPid={$server->master_pid}|Manager_pid={$server->manager_pid}|WorkerId={$worker_id}\n";
}
示例9: processRename
function processRename($serv, $worker_id)
{
global $argv;
if ($worker_id >= $serv->setting['worker_num']) {
swoole_set_process_name("php {$argv[0]}: task");
} else {
swoole_set_process_name("php {$argv[0]}: worker");
}
echo "WorkerStart: MasterPid={$serv->master_pid}|Manager_pid={$serv->manager_pid}";
echo "|WorkerId={$serv->worker_id}|WorkerPid={$serv->worker_pid}\n";
}
示例10: onWorkerStart
public function onWorkerStart($server, $worker_id)
{
global $argv;
opcache_reset();
include_once dirname(__FILE__) . "/test/test.php";
if ($worker_id >= $this->_server->setting['worker_num']) {
swoole_set_process_name("php {$argv[0]} task worker");
} else {
swoole_set_process_name("php {$argv[0]} event worker");
}
}
示例11: onWorkerStart
public function onWorkerStart($server, $workerId)
{
if ($workerId >= ZConfig::getField('socket', 'worker_num')) {
swoole_set_process_name(ZConfig::get('project_name') . " server task num: {$server->worker_id} pid " . $server->worker_pid);
} else {
swoole_set_process_name(ZConfig::get('project_name') . " server worker num: {$server->worker_id} pid " . $server->worker_pid);
}
if (function_exists('opcache_reset')) {
opcache_reset();
}
}
示例12: my_onWorkerStart
function my_onWorkerStart($serv, $worker_id)
{
global $argv;
if ($worker_id >= $serv->setting['worker_num']) {
swoole_set_process_name("php {$argv[0]} task worker");
} else {
swoole_set_process_name("php {$argv[0]} event worker");
}
//echo "WorkerStart|MasterPid={$serv->master_pid}|Manager_pid={$serv->manager_pid}|WorkerId=$worker_id\n";
//$serv->addtimer(500); //500ms
}
示例13: setProcessName
/**
* 设置进程的名称
* @param $name
*/
static function setProcessName($name)
{
if (function_exists('cli_set_process_title')) {
cli_set_process_title($name);
} else {
if (function_exists('swoole_set_process_name')) {
swoole_set_process_name($name);
} else {
trigger_error(__METHOD__ . " failed. require cli_set_process_title or swoole_set_process_name.");
}
}
}
示例14: onWorkerStart
/**
* worker start时调用
* @param unknown $serv
* @param int $worker_id
*/
public function onWorkerStart($serv, $worker_id)
{
global $argv;
if ($worker_id >= $serv->setting['worker_num']) {
swoole_set_process_name("php {$argv[0]}: task");
} else {
swoole_set_process_name("php {$argv[0]}: worker");
}
echo "WorkerStart: MasterPid={$serv->master_pid}|Manager_pid={$serv->manager_pid}|WorkerId={$serv->worker_id}|WorkerPid={$serv->worker_pid}\n";
define('APPLICATION_PATH', dirname(__DIR__));
include APPLICATION_PATH . '/httpindex.php';
}
示例15: processRename
public function processRename($serv, $worker_id)
{
global $argv;
$worker_num = isset($serv->setting['worker_num']) ? $serv->setting['worker_num'] : 1;
$task_worker_num = isset($serv->setting['task_worker_num']) ? $serv->setting['task_worker_num'] : 0;
if ($worker_id >= $worker_num) {
swoole_set_process_name("php {$argv[0]}: task");
} else {
swoole_set_process_name("php {$argv[0]}: worker");
}
echo $serv->master_pid, '--', $serv->manager_pid, '--', $serv->worker_id, '--', $serv->worker_pid, "\n";
}