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 33## 介绍
44一个基于swoole的封装程序
55
6- ## 配置项
6+ ## 实例
77
88``` php
9- return [
9+ $config = [
1010 'timezone' => 'Asia/Shanghai',
1111 'tick_interval_timer' => 30, //秒
1212 'websocket' => [
@@ -54,6 +54,9 @@ return [
5454 'handler' => '',
5555 ],
5656];
57+
58+ $server = new \swoole_websocket_and_tcp_and_udp\Server($config);
59+ $server->run();
5760```
5861
5962## 任务
Original file line number Diff line number Diff line change @@ -97,7 +97,6 @@ public function __construct($config)
9797
9898 $ this ->otherConfig [$ name ] = $ item ;
9999 }
100- // var_dump($this->otherConfig);exit(1);
101100
102101 $ host = $ this ->primaryConfig ['host ' ];
103102 $ port = $ this ->primaryConfig ['port ' ];
@@ -237,7 +236,11 @@ public function Start(\swoole_http_server $server)
237236 $ this ->setProcessName ('master process ' );
238237
239238 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+ }
241244 }
242245 }
243246
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public function checkSwoole($version = '1.10.4')
1212 }
1313
1414 //exec("php --ri swoole | grep Version | awk '{print $3}'");
15- if (!version_compare (\swoole_version (), $ version , '< ' )) {
15+ if (!version_compare (\swoole_version (), $ version , '>= ' )) {
1616 throw new \Exception ("swoole扩展版本小于 {$ version }" );
1717 }
1818 }
You can’t perform that action at this time.
0 commit comments