国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

無法關(guān)閉workerman進(jìn)程

QJ

這是Laravel框架調(diào)用Workerman

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Workerman\Worker;
use PHPSocketIO\SocketIO;
use Config;

class Workerman extends Command
{
    use ConfirmableTrait;

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'workerman:server {action} {-d|daemon=default}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run Workerman Server.';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        global $argv, $argc;

        $action = $this->argument('action');

        if (is_null($this->option('daemon'))) {
            $argv = ;
            $argc = 3;
        } else {
            $argv = ;
            $argc = 2;
        }

        switch ($action) {
            case 'start':
                $port = Config::get('workerman.server.port');
                $events = Config::get('workerman.events');

                $server = new SocketIO($port);

                foreach ($events as $event) {
                    new $event($server);
                }

                Worker::runAll();

                break;
            case 'stop':
                Worker::stopAll();

                break;
            case 'status':
                $this->info(Worker::getStatus());

                break;
            default:
                $this->error($action . ' action does not exist, try one one thoses : start, stop, status');
                break;
        }
    }
}

我用 php artisan workerman:server start -d 可以正常啟動,但是用 php artisan workerman:server stop 卻無法停掉workerman進(jìn)程。

6494 1 0
1個回答

walkor 打賞

啟動腳本里執(zhí)行Worker::stopAll()并不能停止workerman,Worker::stopAll()只有在運行workerman的主進(jìn)程里執(zhí)行才有效,外部其它進(jìn)程執(zhí)行沒有效果。
?
停止Workerman的流程是
1、找到Workerman主進(jìn)程pid
2、給pid發(fā)送SIGINT信號(posix_kill(SIGINT, pid))
3、workerman主進(jìn)程收到SIGINT信號后自身執(zhí)行Worker::stopAll()完成服務(wù)停止。
?
這三個步驟workerman內(nèi)部應(yīng)封裝好,調(diào)用流程是
1、設(shè)置$argv = 'stop';
2、運行Worker::runAll();
?
?

  • 暫無評論
年代過于久遠(yuǎn),無法發(fā)表回答
??