Commit 0caf8fa321aa13e8cbcd84134cd3b032e162c9fe
1 parent
3af35508
[Swoole 集成 ThinkPHP 3.2]
Showing
6 changed files
with
36 additions
and
11 deletions
trunk/.gitignore renamed to .gitignore
@@ -54,4 +54,7 @@ composer.lock | @@ -54,4 +54,7 @@ composer.lock | ||
54 | vendor | 54 | vendor |
55 | 55 | ||
56 | 56 | ||
57 | - trunk/www/.user.ini | ||
58 | \ No newline at end of file | 57 | \ No newline at end of file |
58 | + trunk/www/.user.ini | ||
59 | + trunk/Swoole/tmp/* | ||
60 | + trunk/Swoole/Common/Runtime/* | ||
61 | + trunk/Swoole/Common/Logs/* | ||
59 | \ No newline at end of file | 62 | \ No newline at end of file |
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,13 +6,15 @@ | ||
6 | * Time: 17:29 | 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 | public function index() | 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 | \ No newline at end of file | 21 | \ No newline at end of file |
trunk/Swoole/SwooleServer.php
@@ -20,10 +20,10 @@ class SwooleServer | @@ -20,10 +20,10 @@ class SwooleServer | ||
20 | 'task_worker_num' => 1, //task进程的数量 | 20 | 'task_worker_num' => 1, //task进程的数量 |
21 | 'task_ipc_mode' => 3, //使用消息队列通信,并设置为争抢模式 | 21 | 'task_ipc_mode' => 3, //使用消息队列通信,并设置为争抢模式 |
22 | 'task_max_request' => 10000, //task进程的最大任务数 | 22 | 'task_max_request' => 10000, //task进程的最大任务数 |
23 | - 'daemonize' => 0, //以守护进程执行 | 23 | + 'daemonize' => 1, //以守护进程执行 |
24 | 'max_request' => 10000, | 24 | 'max_request' => 10000, |
25 | 'dispatch_mode' => 2, | 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,7 +40,7 @@ class SwooleServer | ||
40 | 'daemonize' => $this->_setting['daemonize'], | 40 | 'daemonize' => $this->_setting['daemonize'], |
41 | 'max_request' => $this->_setting['max_request'], | 41 | 'max_request' => $this->_setting['max_request'], |
42 | 'dispatch_mode' => $this->_setting['dispatch_mode'], | 42 | 'dispatch_mode' => $this->_setting['dispatch_mode'], |
43 | - //'log_file' => $this->_setting['log_file'] | 43 | + 'log_file' => $this->_setting['log_file'] |
44 | )); | 44 | )); |
45 | $this->_serv->on('Start', array($this, 'onStart')); | 45 | $this->_serv->on('Start', array($this, 'onStart')); |
46 | $this->_serv->on('Connect', array($this, 'onConnect')); | 46 | $this->_serv->on('Connect', array($this, 'onConnect')); |
@@ -53,6 +53,11 @@ class SwooleServer | @@ -53,6 +53,11 @@ class SwooleServer | ||
53 | $this->_serv->on('Shutdown', array($this, 'onShutdown')); | 53 | $this->_serv->on('Shutdown', array($this, 'onShutdown')); |
54 | $this->_serv->on('Close', array($this, 'onClose')); | 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 | $this->_serv->start(); | 61 | $this->_serv->start(); |
57 | } | 62 | } |
58 | 63 | ||
@@ -110,7 +115,7 @@ class SwooleServer | @@ -110,7 +115,7 @@ class SwooleServer | ||
110 | // 绑定默认模块 | 115 | // 绑定默认模块 |
111 | define('BIND_MODULE', 'Cli'); | 116 | define('BIND_MODULE', 'Cli'); |
112 | // 绑定默认控制器 | 117 | // 绑定默认控制器 |
113 | - define('BIND_CONTROLLER', 'Index'); | 118 | + define('BIND_CONTROLLER', 'Index/Index'); |
114 | // 引入ThinkPHP入口文件 | 119 | // 引入ThinkPHP入口文件 |
115 | require_once SWOOLE_PATH . DIRECTORY_SEPARATOR . 'ThinkPHP' . DIRECTORY_SEPARATOR . 'ThinkPHP.php'; | 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,6 +41,9 @@ define('SWOOLE_PATH', __DIR__); | ||
41 | define('SWOOLE_TASK_PID_PATH', SWOOLE_PATH . DIRECTORY_SEPARATOR . 'Swoole' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'swoole-task.pid'); | 41 | define('SWOOLE_TASK_PID_PATH', SWOOLE_PATH . DIRECTORY_SEPARATOR . 'Swoole' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'swoole-task.pid'); |
42 | define('SWOOLE_TASK_NAME_PRE', 'swooleServ'); | 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 | * 加载 swoole server | 48 | * 加载 swoole server |
46 | */ | 49 | */ |