Commit f4d4fe68bf3b883a5be9c33e8cdc84afd63cd447

Authored by luoyanshou
1 parent 208b11c4

[Swoole 集成 ThinkPHP 3.2]

Showing 1 changed file with 10 additions and 9 deletions
trunk/Swoole/SwooleServer.php
... ... @@ -23,7 +23,7 @@ class SwooleServer
23 23 'daemonize' => 1, //以守护进程执行
24 24 'max_request' => 10000,
25 25 'dispatch_mode' => 2,
26   - 'log_file' => CODE_ROOT . D_S. 'Common' . D_S . 'Logs' . D_S . '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  
... ... @@ -34,13 +34,13 @@ class SwooleServer
34 34 {
35 35 $this->_serv = new swoole_server($this->_setting['host'], $this->_setting['port']);
36 36 $this->_serv->set(array(
37   - 'worker_num' => $this->_setting['worker_num'],
38   - 'task_worker_num' => $this->_setting['task_worker_num'],
39   - 'task_ipc_mode ' => $this->_setting['task_ipc_mode'],'task_max_request' => $this->_setting['task_max_request'],
40   - 'daemonize' => $this->_setting['daemonize'],
41   - 'max_request' => $this->_setting['max_request'],
42   - 'dispatch_mode' => $this->_setting['dispatch_mode'],
43   - 'log_file' => $this->_setting['log_file']
  37 + 'worker_num' => $this->_setting['worker_num'],
  38 + 'task_worker_num' => $this->_setting['task_worker_num'],
  39 + 'task_ipc_mode ' => $this->_setting['task_ipc_mode'], 'task_max_request' => $this->_setting['task_max_request'],
  40 + 'daemonize' => $this->_setting['daemonize'],
  41 + 'max_request' => $this->_setting['max_request'],
  42 + 'dispatch_mode' => $this->_setting['dispatch_mode'],
  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'));
... ... @@ -55,7 +55,8 @@ class SwooleServer
55 55  
56 56 // 判断日志文件是否存在 不存在则创建
57 57 if (!file_exists($this->_setting['log_file'])) {
58   - exec('touch ' . $this->_setting['log_file']);
  58 + $cmd = 'mkdir -p ' . dirname($this->_setting['log_file']) . '&& touch ' . $this->_setting['log_file'];
  59 + exec($cmd);
59 60 }
60 61  
61 62 $this->_serv->start();
... ...