-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
Description
[2022-05-05 11:42:38 @7347.0] WARNING ProcessPool::wait(): worker#0 abnormal exit, status=0, signal=11
A bug occurred in Swoole-v4.8.9, please report it.
The Swoole developers probably don't know about it,
and unless you report it, chances are it won't be fixed.
You can read How to report a bug doc before submitting any bug reports:
https://github.com/swoole/swoole-src/blob/master/.github/ISSUE.md
Please do not send bug reports in the mailing list or personal letters.
The issue page is also suitable to submit feature requests.
OS: Linux 3.10.0-1160.59.1.el7.x86_64 #1 SMP Wed Feb 23 16:47:03 UTC 2022 x86_64
GCC_VERSION: 4.8.5 20150623 (Red Hat 4.8.5-44)
PHP_VERSION : 7.4.29
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Swoole\Process;
use Swoole\Coroutine;
use OSS\OssClient;
use OSS\Core\OssException;
Co::set(['hook_flags'=> SWOOLE_HOOK_ALL]);
//参数配置
$oss_config = [];
// Process::daemon();
swoole_set_process_name("msgprocess");
$pool = new Process\Pool(1);
$pool->set(
[
'enable_static_handler' => true,
'enable_coroutine' => true
]
);
$pool->on('WorkerStart', function (Process\Pool $pool, $workerId) use($oss_config){
/** 当前是 Worker 进程 */
Process::signal(SIGTERM, function () use (&$running) {
});
$file = 'ca-cert.pem';
$conf = new \RdKafka\Conf();
$conf->set('sasl.mechanisms', 'PLAIN');
$conf->set('api.version.request', 'true');
$conf->set('sasl.username', '');
$conf->set('sasl.password', '');
$conf->set('security.protocol', 'SASL_SSL');
$conf->set('ssl.ca.location', $file);
$conf->set('group.id', 'workwx-message');
$conf->set('metadata.broker.list', '');
$consumer = new \RdKafka\KafkaConsumer($conf);
$consumer->subscribe(['crm_wechat_message']);
while (true) {
$message = $consumer->consume(1000);
switch ($message->err) {
case RD_KAFKA_RESP_ERR_NO_ERROR:
$message_body = json_decode($message->payload, true);
echo "进程ID {$workerId} 消息消息:{$message->payload}\n";
break;
case RD_KAFKA_RESP_ERR__PARTITION_EOF:
break;
case RD_KAFKA_RESP_ERR__TIMED_OUT:
break;
default:
throw new \Exception($message->errstr(), $message->err);
break;
}
}
});
$pool->on('WorkerStop', function (\Swoole\Process\Pool $pool, $workerId) {
echo("[Worker #{$workerId}] WorkerStop\n");
});
$pool->start();