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


PHP Daemon::logpointerAsync方法代码示例

本文整理汇总了PHP中PHPDaemon\Core\Daemon::logpointerAsync方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::logpointerAsync方法的具体用法?PHP Daemon::logpointerAsync怎么用?PHP Daemon::logpointerAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPDaemon\Core\Daemon的用法示例。


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

示例1: run

 /**
  * Runtime of Worker process.
  * @return void
  */
 protected function run()
 {
     if (Daemon::$process instanceof Master) {
         Daemon::$process->unregisterSignals();
     }
     EventLoop::init();
     Daemon::$process = $this;
     if (Daemon::$logpointerAsync) {
         Daemon::$logpointerAsync->fd = null;
         Daemon::$logpointerAsync = null;
     }
     class_exists('Timer');
     if (Daemon::$config->autogc->value > 0) {
         gc_enable();
     } else {
         gc_disable();
     }
     $this->prepareSystemEnv();
     $this->registerEventSignals();
     FileSystem::init();
     // re-init
     FileSystem::initEvent();
     Daemon::openLogs();
     $this->fileWatcher = new FileWatcher();
     $this->IPCManager = Daemon::$appResolver->getInstanceByAppName('\\PHPDaemon\\IPCManager\\IPCManager');
     if (!$this->IPCManager) {
         $this->log('cannot instantiate IPCManager');
     }
     EventLoop::$instance->run();
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:34,代码来源:IPC.php

示例2: 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 Thread\Worker && FileSystem::$supported) {
             FileSystem::open(Daemon::$config->logstorage->value, 'a!', function ($file) {
                 Daemon::$logpointerAsync = $file;
                 if (!$file) {
                     return;
                 }
             });
         }
     } else {
         Daemon::$logpointer = null;
         Daemon::$logpointerAsync = null;
     }
 }
开发者ID:aleksraiden,项目名称:phpdaemon-sockjs-example,代码行数:29,代码来源:Daemon.php

示例3: run

 /**
  * Runtime of Worker process.
  * @return void
  */
 protected function run()
 {
     $this->lambdaCache = new CappedStorageHits();
     $this->lambdaCache->setMaxCacheSize(Daemon::$config->lambdacachemaxsize->value);
     $this->lambdaCache->setCapWindow(Daemon::$config->lambdacachecapwindow->value);
     $this->callbacks = new StackCallbacks();
     if (Daemon::$process instanceof Master) {
         Daemon::$process->unregisterSignals();
     }
     if (Daemon::$process && Daemon::$process->eventBase) {
         Daemon::$process->eventBase->reinit();
         $this->eventBase = Daemon::$process->eventBase;
     } else {
         $this->eventBase = new \EventBase();
     }
     Daemon::$process = $this;
     if (Daemon::$logpointerAsync) {
         $oldfd = Daemon::$logpointerAsync->fd;
         Daemon::$logpointerAsync->fd = null;
         Daemon::$logpointerAsync = null;
     }
     class_exists('Timer');
     $this->autoReloadLast = time();
     $this->reloadDelay = Daemon::$config->mpmdelay->value + 2;
     $this->setState(Daemon::WSTATE_PREINIT);
     if (Daemon::$config->autogc->value > 0) {
         gc_enable();
         gc_collect_cycles();
     } else {
         gc_disable();
     }
     if (Daemon::$runworkerMode) {
         if (!Daemon::$config->verbosetty->value) {
             fclose(STDIN);
             fclose(STDOUT);
             fclose(STDERR);
         }
         Daemon::$appResolver->preload(true);
     }
     $this->prepareSystemEnv();
     $this->overrideNativeFuncs();
     $this->setState(Daemon::WSTATE_INIT);
     $this->dnsBase = new \EventDnsBase($this->eventBase, false);
     // @TODO: test with true
     $this->registerEventSignals();
     FileSystem::init();
     FileSystem::initEvent();
     Daemon::openLogs();
     $this->IPCManager = Daemon::$appResolver->getInstanceByAppName('\\PHPDaemon\\IPCManager\\IPCManager');
     if (!$this->IPCManager) {
         $this->log('cannot instantiate IPCManager');
     }
     Daemon::$appResolver->preload();
     foreach (Daemon::$appInstances as $app) {
         foreach ($app as $appInstance) {
             if (!$appInstance->ready) {
                 $appInstance->ready = true;
                 $appInstance->onReady();
             }
         }
     }
     $this->setState(Daemon::WSTATE_IDLE);
     Timer::add(function ($event) {
         if (!Daemon::$runworkerMode) {
             if ($this->IPCManager) {
                 $this->IPCManager->ensureConnection();
             }
         }
         $this->breakMainLoopCheck();
         if ($this->breakMainLoop) {
             $this->eventBase->exit();
             return;
         }
         if (Daemon::checkAutoGC()) {
             $this->callbacks->push(function ($thread) {
                 gc_collect_cycles();
             });
             $this->eventBase->exit();
         }
         $event->timeout();
     }, 1000000.0 * 1, 'breakMainLoopCheck');
     if (Daemon::$config->autoreload->value > 0) {
         Timer::add(function ($event) {
             static $n = 0;
             $list = get_included_files();
             $s = sizeof($list);
             if ($s > $n) {
                 $slice = array_map('realpath', array_slice($list, $n));
                 Daemon::$process->IPCManager->sendPacket(['op' => 'addIncludedFiles', 'files' => $slice]);
                 $n = $s;
             }
             $event->timeout();
         }, 1000000.0 * Daemon::$config->autoreload->value, 'watchIncludedFiles');
     }
     while (!$this->breakMainLoop) {
         $this->callbacks->executeAll($this);
//.........这里部分代码省略.........
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:101,代码来源:Worker.php


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