function __swoole($daemonize = true) { $swoole = new CxSwoole(); $swoole->bootstrap('Bootstrap', $swoole); $swoole->setOption('daemonize', $daemonize); $swoole->run(); }
public function __construct(CxSwoole $swoole) { $swoole->notfound(array($this, 'onNotfound')); $swoole->error(array($this, 'onError')); //$swoole->setCallback('task', array($this, 'onTask')); //$swoole->setCallback('finish', array($this, 'onFinish')); //$swoole->setCallback('timer', array($this, 'onTimer')); //$swoole->setCallback('workerstart', array($this, 'onWorkerStart')); }
public function onWorkerStart($serv, $worker_id) { $config = array(); $include = explode(':', PATH_AUTOINCLUDE); $include[] = PATH_DAOS; $include[] = PATH_COMMON; $include[] = PATH_CONTROLLER; foreach ($include as $val) { $auto = glob($val . '*.php'); if ($auto) { foreach ($auto as $v) { include_once $v; } } } self::$config = $config; //判断是否为worker进程 if ($worker_id < $serv->setting['worker_num']) { CxSwoole::$server = $serv; CxSwoole::$workid = $worker_id; } $this->workerstart and call_user_func($this->workerstart, $serv, $worker_id); }
<?php //开启Session //session_start(); //关闭所有错误警告 //ini_set("display_errors", 0); //加载配置文件 include "config.mvc.php"; $swoole = new CxSwoole(); $swoole->bootstrap('Bootstrap', $swoole); $swoole->run();