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


PHP Worker::run方法代码示例

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


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

示例1: run

 /**
  * Run webserver instance.
  *
  * @see Workerman.Worker::run()
  */
 public function run()
 {
     $this->_onWorkerStart = $this->onWorkerStart;
     $this->onWorkerStart = array($this, 'onWorkerStart');
     $this->onMessage = array($this, 'onMessage');
     parent::run();
 }
开发者ID:google2013,项目名称:Workerman,代码行数:12,代码来源:WebServer.php

示例2: run

 public function run()
 {
     $this->onConnect = array($this, 'onConnect');
     // onMessage禁止用户设置回调
     $this->onMessage = array($this, 'onMessage');
     // 保存用户的回调,当对应的事件发生时触发
     $this->onClose = array($this, 'onClose');
     // 记录进程启动的时间
     $this->_startTime = time();
     // 运行父方法
     parent::run();
 }
开发者ID:andy0010,项目名称:GatewayWorker,代码行数:12,代码来源:Register.php

示例3: run

 /**
  * 运行
  * @return void
  */
 public function run()
 {
     // 设置onMessage连接回调
     $this->onConnect = array($this, 'onConnect');
     // 设置onMessage回调
     $this->onMessage = array($this, 'onMessage');
     // 设置onClose回调
     $this->onClose = array($this, 'onClose');
     // 记录进程启动的时间
     $this->_startTime = time();
     // 运行父方法
     parent::run();
 }
开发者ID:ATAup,项目名称:workerman-chat,代码行数:17,代码来源:Register.php

示例4: run

 /**
  * 运行
  * @see Workerman.Worker::run()
  */
 public function run()
 {
     echo 123;
     $htmlStr = file_get_contents('http://www.baidu.com');
     for ($i = 0; $i < 200; $i++) {
         if ($this->count < 200) {
             file_put_contents('/www/html/workerman/html/chat1/test.log', $this->count++ . "\r\n", FILE_APPEND);
             sleep(3);
         }
     }
     echo 456;
     parent::run();
 }
开发者ID:suhanyujie,项目名称:digitalOceanVps,代码行数:17,代码来源:MyWorker.php

示例5: run

 /**
  * 运行
  * @see Workerman.Worker::run()
  */
 public function run()
 {
     // 保存用户的回调,当对应的事件发生时触发
     $this->_onWorkerStart = $this->onWorkerStart;
     $this->onWorkerStart = array($this, 'onWorkerStart');
     // 保存用户的回调,当对应的事件发生时触发
     $this->_onConnect = $this->onConnect;
     $this->onConnect = array($this, 'onClientConnect');
     // onMessage禁止用户设置回调
     $this->onMessage = array($this, 'onClientMessage');
     // 保存用户的回调,当对应的事件发生时触发
     $this->_onClose = $this->onClose;
     $this->onClose = array($this, 'onClientClose');
     // 保存用户的回调,当对应的事件发生时触发
     $this->_onWorkerStop = $this->onWorkerStop;
     $this->onWorkerStop = array($this, 'onWorkerStop');
     // 记录进程启动的时间
     $this->_startTime = time();
     // 运行父方法
     parent::run();
 }
开发者ID:Nathanyang,项目名称:web-msg-sender,代码行数:25,代码来源:Gateway.php

示例6: 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");
     }
 }
开发者ID:TongJiankang,项目名称:Workerman,代码行数:33,代码来源:Worker.php

示例7: 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");
     }
 }
开发者ID:hongbo819,项目名称:webChat,代码行数:27,代码来源:Worker.php

示例8: run

 /**
  * 运行
  * @see Workerman.Worker::run()
  */
 public function run()
 {
     $this->_onWorkerStart = $this->onWorkerStart;
     $this->_onWorkerReload = $this->onWorkerReload;
     $this->onWorkerStart = array($this, 'onWorkerStart');
     $this->onWorkerReload = array($this, 'onWorkerReload');
     parent::run();
 }
开发者ID:jiayuanpulto,项目名称:workerman-chat,代码行数:12,代码来源:BusinessWorker.php

示例9: 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");
     }
 }
开发者ID:xqbumu,项目名称:Workerman,代码行数:35,代码来源:Worker.php


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