File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 3
3
## 介绍
4
4
一个基于swoole的封装程序
5
5
6
- ## 配置项
6
+ ## 实例
7
7
8
8
``` php
9
- return [
9
+ $config = [
10
10
'timezone' => 'Asia/Shanghai',
11
11
'tick_interval_timer' => 30, //秒
12
12
'websocket' => [
@@ -54,6 +54,9 @@ return [
54
54
'handler' => '',
55
55
],
56
56
];
57
+
58
+ $server = new \swoole_websocket_and_tcp_and_udp\Server($config);
59
+ $server->run();
57
60
```
58
61
59
62
## 任务
Original file line number Diff line number Diff line change @@ -97,7 +97,6 @@ public function __construct($config)
97
97
98
98
$ this ->otherConfig [$ name ] = $ item ;
99
99
}
100
- // var_dump($this->otherConfig);exit(1);
101
100
102
101
$ host = $ this ->primaryConfig ['host ' ];
103
102
$ port = $ this ->primaryConfig ['port ' ];
@@ -237,7 +236,11 @@ public function Start(\swoole_http_server $server)
237
236
$ this ->setProcessName ('master process ' );
238
237
239
238
if (version_compare (\swoole_version (), '1.10.4 ' , '>= ' )) {
240
- file_put_contents ($ this ->config ['pid_file ' ], $ server ->master_pid );
239
+ if (isset ($ this ->config ['pid_file ' ])) {
240
+ if (is_dir (dirname ($ this ->config ['pid_file ' ]))) {
241
+ file_put_contents ($ this ->config ['pid_file ' ], $ server ->master_pid );
242
+ }
243
+ }
241
244
}
242
245
}
243
246
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public function checkSwoole($version = '1.10.4')
12
12
}
13
13
14
14
//exec("php --ri swoole | grep Version | awk '{print $3}'");
15
- if (!version_compare (\swoole_version (), $ version , '< ' )) {
15
+ if (!version_compare (\swoole_version (), $ version , '>= ' )) {
16
16
throw new \Exception ("swoole扩展版本小于 {$ version }" );
17
17
}
18
18
}
You can’t perform that action at this time.
0 commit comments