|
@@ -30,7 +30,7 @@ class RefillSender
|
|
|
$res = Swoole\Coroutine::stats();
|
|
|
$num = $res['coroutine_num'];
|
|
|
|
|
|
- if($num > 3000) {
|
|
|
+ if($num > 1000) {
|
|
|
sleep(1);
|
|
|
continue;
|
|
|
}
|
|
@@ -60,12 +60,46 @@ class RefillSender
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Log::record("send message start",Log::DEBUG);
|
|
|
-go(function () {
|
|
|
- $sender = new RefillSender();
|
|
|
- $sender->sendex();
|
|
|
-});
|
|
|
-Log::record("send message end",Log::DEBUG);
|
|
|
+$process_count = 8;
|
|
|
+
|
|
|
+$workers = [];
|
|
|
+for ($i = 0; $i < $process_count;$i++)
|
|
|
+{
|
|
|
+ $process = new Swoole\Process(function(Swoole\Process $worker)
|
|
|
+ {
|
|
|
+ Base::run_util();
|
|
|
+ set_error_handler('handle_error');
|
|
|
+
|
|
|
+ go(function () {
|
|
|
+ $sender = new RefillSender();
|
|
|
+ $sender->sendex();
|
|
|
+ });
|
|
|
+ }, false, false, true);
|
|
|
+
|
|
|
+ $pid = $process->start();
|
|
|
+ $workers[$pid] = $process;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Log::record("main process start wait sub process....",Log::DEBUG);
|
|
|
+while (true)
|
|
|
+{
|
|
|
+ if($status = Swoole\Process::wait(true)) {
|
|
|
+ Log::record("Sub process #{$status['pid']} quit, code={$status['code']}, signal={$status['signal']}",Log::DEBUG);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach ($workers as $pid => $worker)
|
|
|
+ {
|
|
|
+ Swoole\Process::kill($pid,SIGTERM);
|
|
|
+ if($status = Swoole\Process::wait(true)) {
|
|
|
+ Log::record("Graceful Recycled #{$status['pid']}, code={$status['code']}, signal={$status['signal']}",Log::DEBUG);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+Log::record("Quit all",Log::DEBUG);
|
|
|
|
|
|
|
|
|
|