Shouldn't write pid to the file when pid_file is not configured for coroutine style server. (#3365)

* Shouldn't write pid to the file when the config of pid_file is not configured.

* Update async-queue.md
This commit is contained in:
李铭昕 2021-03-14 13:29:35 +08:00 committed by GitHub
parent af2c639bb1
commit 8963a78b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View File

@ -11,6 +11,10 @@
- [#3364](https://github.com/hyperf/hyperf/pull/3364) Optimized `phar:build` that you can run phar without `php`, such as `./composer.phar` instead of `php composer.phar`.
## Changed
- [#3365](https://github.com/hyperf/hyperf/pull/3365) Shouldn't write pid to the file when `pid_file` is not configured for coroutine style server.
# v2.1.9 - 2021-03-08
## Fixed

View File

@ -1,6 +1,6 @@
# 异步队列
异步队列区别于 `RabbitMQ` `Kafka` 等消息队列,它只提供一种 `异步处理``异步延时处理` 的能力,并 **不能** 严格地保证消息的持久化和 **不支持** ACK 应答机制。
异步队列区别于 `RabbitMQ` `Kafka` 等消息队列,它只提供一种 `异步处理``异步延时处理` 的能力,并 **不能** 严格地保证消息的持久化和 **不支持** 完备的 ACK 应答机制。
## 安装
@ -517,3 +517,12 @@ return [
];
```
## 异步驱动之间的区别
- Hyperf\AsyncQueue\Driver\RedisDriver::class
此异步驱动会将整个 `JOB` 进行序列化,当投递即时队列后,会 `lpush``list` 结构中,投递延时队列,会 `zadd``zset` 结构中。
所以,如果 `Job` 的参数完全一致的情况,在延时队列中就会出现后投递的消息 **覆盖** 前面投递的消息的问题。
如果不想出现延时消息覆盖的情况,只需要在 `Job` 里增加一个唯一的 `uniqid`,或者在使用 `注解` 的方法上增加一个 `uniqid` 的入参即可。

View File

@ -109,8 +109,8 @@ class CoroutineServer implements ServerInterface
}
/**
* @deprecated v2.2
* @param mixed $server
* @deprecated v2.2
*/
public static function isCoroutineServer($server): bool
{
@ -235,7 +235,9 @@ class CoroutineServer implements ServerInterface
private function writePid(): void
{
$config = $this->container->get(ConfigInterface::class);
$file = $config->get('server.settings.pid_file', BASE_PATH . '/runtime/hyperf.pid');
file_put_contents($file, getmypid());
$file = $config->get('server.settings.pid_file');
if ($file) {
file_put_contents($file, getmypid());
}
}
}