Commit 0caf8fa321aa13e8cbcd84134cd3b032e162c9fe
1 parent
3af35508
[Swoole 集成 ThinkPHP 3.2]
Showing
6 changed files
with
36 additions
and
11 deletions
trunk/.gitignore renamed to .gitignore
trunk/Swoole/Cli/Controller/AbstractController.class.php
0 → 100644
trunk/Swoole/Cli/Controller/IndexController.class.php renamed to trunk/Swoole/Cli/Controller/Index/IndexController.class.php
... | ... | @@ -6,13 +6,15 @@ |
6 | 6 | * Time: 17:29 |
7 | 7 | */ |
8 | 8 | |
9 | -namespace Cli\Controller; | |
9 | +namespace Cli\Controller\Index; | |
10 | 10 | |
11 | -class IndexController | |
11 | +use Cli\Controller\AbstractController; | |
12 | + | |
13 | +class IndexController extends AbstractController | |
12 | 14 | { |
13 | 15 | public function index() |
14 | 16 | { |
15 | - print_r(C('MODULE_DENY_LIST')); | |
16 | - //echo "Swoole 服务端已启动。 \n"; | |
17 | + //print_r(C('MODULE_DENY_LIST')); | |
18 | + echo "Swoole 已启动。\n"; | |
17 | 19 | } |
18 | 20 | } |
19 | 21 | \ No newline at end of file | ... | ... |
trunk/Swoole/SwooleServer.php
... | ... | @@ -20,10 +20,10 @@ class SwooleServer |
20 | 20 | 'task_worker_num' => 1, //task进程的数量 |
21 | 21 | 'task_ipc_mode' => 3, //使用消息队列通信,并设置为争抢模式 |
22 | 22 | 'task_max_request' => 10000, //task进程的最大任务数 |
23 | - 'daemonize' => 0, //以守护进程执行 | |
23 | + 'daemonize' => 1, //以守护进程执行 | |
24 | 24 | 'max_request' => 10000, |
25 | 25 | 'dispatch_mode' => 2, |
26 | - 'log_file' => SWOOLE_PATH . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'Runtime' . DIRECTORY_SEPARATOR . 'Logs' . DIRECTORY_SEPARATOR . 'Swoole' . date('Ymd') . '.log', //日志 | |
26 | + 'log_file' => CODE_ROOT . D_S. 'Common' . D_S . 'Logs' . D_S . 'Swoole' . date('Ymd') . '.log', //日志 | |
27 | 27 | ); |
28 | 28 | } |
29 | 29 | |
... | ... | @@ -40,7 +40,7 @@ class SwooleServer |
40 | 40 | 'daemonize' => $this->_setting['daemonize'], |
41 | 41 | 'max_request' => $this->_setting['max_request'], |
42 | 42 | 'dispatch_mode' => $this->_setting['dispatch_mode'], |
43 | - //'log_file' => $this->_setting['log_file'] | |
43 | + 'log_file' => $this->_setting['log_file'] | |
44 | 44 | )); |
45 | 45 | $this->_serv->on('Start', array($this, 'onStart')); |
46 | 46 | $this->_serv->on('Connect', array($this, 'onConnect')); |
... | ... | @@ -53,6 +53,11 @@ class SwooleServer |
53 | 53 | $this->_serv->on('Shutdown', array($this, 'onShutdown')); |
54 | 54 | $this->_serv->on('Close', array($this, 'onClose')); |
55 | 55 | |
56 | + // 判断日志文件是否存在 不存在则创建 | |
57 | + if (!file_exists($this->_setting['log_file'])) { | |
58 | + exec('touch ' . $this->_setting['log_file']); | |
59 | + } | |
60 | + | |
56 | 61 | $this->_serv->start(); |
57 | 62 | } |
58 | 63 | |
... | ... | @@ -110,7 +115,7 @@ class SwooleServer |
110 | 115 | // 绑定默认模块 |
111 | 116 | define('BIND_MODULE', 'Cli'); |
112 | 117 | // 绑定默认控制器 |
113 | - define('BIND_CONTROLLER', 'Index'); | |
118 | + define('BIND_CONTROLLER', 'Index/Index'); | |
114 | 119 | // 引入ThinkPHP入口文件 |
115 | 120 | require_once SWOOLE_PATH . DIRECTORY_SEPARATOR . 'ThinkPHP' . DIRECTORY_SEPARATOR . 'ThinkPHP.php'; |
116 | 121 | } | ... | ... |
trunk/Swoole/tmp/swoole-task.pid deleted
100644 → 0
trunk/swoole.php
... | ... | @@ -41,6 +41,9 @@ define('SWOOLE_PATH', __DIR__); |
41 | 41 | define('SWOOLE_TASK_PID_PATH', SWOOLE_PATH . DIRECTORY_SEPARATOR . 'Swoole' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'swoole-task.pid'); |
42 | 42 | define('SWOOLE_TASK_NAME_PRE', 'swooleServ'); |
43 | 43 | |
44 | +define('D_S', DIRECTORY_SEPARATOR); | |
45 | +define('CODE_ROOT', SWOOLE_PATH.D_S.'Swoole'); | |
46 | + | |
44 | 47 | /** |
45 | 48 | * 加载 swoole server |
46 | 49 | */ | ... | ... |