本文整理匯總了PHP中Daemon::logpointerAsync方法的典型用法代碼示例。如果您正苦於以下問題:PHP Daemon::logpointerAsync方法的具體用法?PHP Daemon::logpointerAsync怎麽用?PHP Daemon::logpointerAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Daemon
的用法示例。
在下文中一共展示了Daemon::logpointerAsync方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: openLogs
/**
* Open logs.
* @return void
*/
public static function openLogs()
{
if (Daemon::$config->logging->value) {
Daemon::$logpointer = fopen(Daemon::$config->logstorage->value, 'a');
if (isset(Daemon::$config->group->value)) {
chgrp(Daemon::$config->logstorage->value, Daemon::$config->group->value);
// @TODO: rewrite to async I/O
}
if (isset(Daemon::$config->user->value)) {
chown(Daemon::$config->logstorage->value, Daemon::$config->user->value);
// @TODO: rewrite to async I/O
}
if (Daemon::$process instanceof Daemon_WorkerThread && FS::$supported) {
FS::open(Daemon::$config->logstorage->value, 'a!', function ($file) {
Daemon::$logpointerAsync = $file;
if (!$file) {
return;
}
});
}
} else {
Daemon::$logpointer = null;
Daemon::$logpointerAsync = null;
}
}
示例2: run
/**
* Runtime of Worker process.
* @return void
*/
public function run()
{
FS::init();
Daemon::$process = $this;
if (Daemon::$logpointerAsync) {
$oldfd = Daemon::$logpointerAsync->fd;
Daemon::$logpointerAsync->fd = null;
Daemon::$logpointerAsync = null;
}
$this->autoReloadLast = time();
$this->reloadDelay = Daemon::$config->mpmdelay->value + 2;
$this->setStatus(4);
if (Daemon::$config->autogc->value > 0) {
gc_enable();
} else {
gc_disable();
}
$this->prepareSystemEnv();
$this->overrideNativeFuncs();
$this->setStatus(6);
$this->eventBase = event_base_new();
$this->registerEventSignals();
FS::init();
// re-init
FS::initEvent();
Daemon::openLogs();
$this->fileWatcher = new FileWatcher();
$this->IPCManager = Daemon::$appResolver->getInstanceByAppName('IPCManager');
Daemon::$appResolver->preload();
foreach (Daemon::$appInstances as $app) {
foreach ($app as $appInstance) {
if (!$appInstance->ready) {
$appInstance->ready = TRUE;
$appInstance->onReady();
}
}
}
$this->setStatus(1);
Timer::add(function ($event) {
$self = Daemon::$process;
if ($self->checkState() !== TRUE) {
$self->closeSockets();
$self->breakMainLoop = TRUE;
event_base_loopexit($self->eventBase);
return;
}
$event->timeout();
}, 1000000.0 * 1, 'checkState');
if (Daemon::$config->autoreload->value > 0) {
Timer::add(function ($event) {
$self = Daemon::$process;
static $n = 0;
$inc = array_unique(array_map('realpath', get_included_files()));
$s = sizeof($inc);
if ($s > $n) {
$slice = array_slice($inc, $n);
Daemon::$process->IPCManager->sendPacket(array('op' => 'addIncludedFiles', 'files' => $slice));
$n = $s;
}
$event->timeout();
}, 1000000.0 * Daemon::$config->autoreload->value, 'watchIncludedFiles');
}
while (!$this->breakMainLoop) {
event_base_loop($this->eventBase);
}
}