Skip to content

Commit 34fc1eb

Browse files
committed
提示与说明优化
1 parent 85c1eea commit 34fc1eb

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
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
## 任务

src/Server.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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

src/common/Swoole.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)