1 Star 0 Fork 17

bbhkxd/robotphp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
testJob.php 880 Bytes
一键复制 编辑 原始数据 按行查看 历史
黄超h 提交于 2023-06-06 14:44 . 提交代码
<?php
/**
* Created by PhpStorm.
* User: WIN10
* Date: 2021/12/10
* Time: 13:21
*/
use Swoole\Process;
use Swoole\Coroutine;
$pool = new Process\Pool(5);
$pool->set(['enable_coroutine' => true]);
$pool->on('WorkerStart', function (Process\Pool $pool, $workerId) {
/** 当前是 Worker 进程 */
static $running = true;
Process::signal(SIGTERM, function () use (&$running) {
$running = false;
echo "TERM\n";
});
Swoole\Timer::tick(100,function(){
echo "============================";
});
echo("[Worker #{$workerId}] WorkerStart, pid: " . posix_getpid() . "\n");
while ($running) {
Coroutine::sleep(1);
echo "sleep 1\n";
}
});
$pool->on('WorkerStop', function (\Swoole\Process\Pool $pool, $workerId) {
echo("[Worker #{$workerId}] WorkerStop\n");
});
$pool->start();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/bbhkxd/robotphp.git
[email protected]:bbhkxd/robotphp.git
bbhkxd
robotphp
robotphp
master

搜索帮助