本文整理汇总了PHP中Workerman\Worker::getSocketName方法的典型用法代码示例。如果您正苦于以下问题:PHP Worker::getSocketName方法的具体用法?PHP Worker::getSocketName怎么用?PHP Worker::getSocketName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workerman\Worker
的用法示例。
在下文中一共展示了Worker::getSocketName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forkOneWorker
/**
* 创建一个子进程
* @param Worker $worker
* @throws Exception
*/
protected static function forkOneWorker($worker)
{
$pid = pcntl_fork();
// 主进程记录子进程pid
if ($pid > 0) {
self::$_pidMap[$worker->workerId][$pid] = $pid;
} elseif (0 === $pid) {
// 启动过程中尝试重定向标准输出
if (self::$_status === self::STATUS_STARTING) {
self::resetStd();
}
self::$_pidMap = array();
self::$_workers = array($worker->workerId => $worker);
Timer::delAll();
self::setProcessTitle('WorkerMan: worker process ' . $worker->name . ' ' . $worker->getSocketName());
self::setProcessUser($worker->user);
$worker->run();
exit(250);
} else {
throw new Exception("forkOneWorker fail");
}
}
示例2: forkOneWorker
/**
* Fork one worker process.
* @param Worker $worker
* @throws Exception
*/
protected static function forkOneWorker($worker)
{
$pid = pcntl_fork();
// Get available worker id.
$id = self::getId($worker->workerId, 0);
// For master process.
if ($pid > 0) {
self::$_pidMap[$worker->workerId][$pid] = $pid;
self::$_idMap[$worker->workerId][$id] = $pid;
} elseif (0 === $pid) {
if ($worker->reusePort) {
$worker->listen();
}
if (self::$_status === self::STATUS_STARTING) {
self::resetStd();
}
self::$_pidMap = array();
self::$_workers = array($worker->workerId => $worker);
Timer::delAll();
self::setProcessTitle('WorkerMan: worker process ' . $worker->name . ' ' . $worker->getSocketName());
$worker->setUserAndGroup();
$worker->id = $id;
$worker->run();
exit(250);
} else {
throw new Exception("forkOneWorker fail");
}
}
示例3: forkOneWorker
/**
* 创建一个子进程
* @param Worker $worker
* @throws Exception
*/
protected static function forkOneWorker($worker)
{
$pid = pcntl_fork();
// 获得可用的id
$id = self::getId($worker->workerId, 0);
// 主进程记录子进程pid
if ($pid > 0) {
self::$_pidMap[$worker->workerId][$pid] = $pid;
self::$_idMap[$worker->workerId][$id] = $pid;
} elseif (0 === $pid) {
// 如果设置了端口复用,则在子进程执行监听
if ($worker->reusePort) {
$worker->listen();
}
// 启动过程中尝试重定向标准输出
if (self::$_status === self::STATUS_STARTING) {
self::resetStd();
}
self::$_pidMap = array();
self::$_workers = array($worker->workerId => $worker);
Timer::delAll();
self::setProcessTitle('WorkerMan: worker process ' . $worker->name . ' ' . $worker->getSocketName());
$worker->setProcessUserAndRoot();
$worker->id = $id;
$worker->run();
exit(250);
} else {
throw new Exception("forkOneWorker fail");
}
}