src/MQK/Process/AbstractWorker.php
public function start()
    {
        $pid = pcntl_fork();

        if (-1 == $pid) {
            exit(1);
        } else if ($pid) {
            $this->id = $pid;
            return $pid;
        }
        pcntl_signal(SIGINT, function ($signalNumber) {
            $this->logger->debug("process {$this->id} got int signal");
            $this->quit();
            exit(0);
        });
        pcntl_signal(SIGQUIT, function ($signalNumber) {
            $this->logger->debug("process {$this->id} got quit signal");
            $this->graceFullQuit();
        });
        pcntl_signal(SIGTERM, function ($signalNumber) {
            $this->logger->debug("process {$this->id} got terminal signal");
            $this->quit();
            exit(0);
        });
        pcntl_signal(SIGUSR1, function ($sigalNumber) {
            $this->logger->debug("reopen logs");
            $this->reopenLogs();
        });
        $this->id = posix_getpid();
        $this->createdAt = time();

        // TODO: 进程退出后通知
        $this->run();
        exit();
    }
public function start()
    {
        $pid = pcntl_fork();

        if (-1 == $pid) {
            exit(1);
        } else if ($pid) {
            $this->id = $pid;
            return $pid;
        }
        pcntl_signal(SIGINT, function ($signalNumber) {
            $this->logger->debug("process {$this->id} got int signal");
            $this->quit();
            exit(0);
        });
        pcntl_signal(SIGQUIT, function ($signalNumber) {
            $this->logger->debug("process {$this->id} got quit signal");
            $this->graceFullQuit();
        });
        pcntl_signal(SIGTERM, function ($signalNumber) {
            $this->logger->debug("process {$this->id} got terminal signal");
            $this->quit();
            exit(0);
        });
        pcntl_signal(SIGUSR1, function ($sigalNumber) {
            $this->logger->debug("reopen logs");
            $this->reopenLogs();
        });
        $this->id = posix_getpid();
        $this->createdAt = time();

        // TODO: 进程退出后通知
        $this->run();
        exit();
    }
启动进程
@return int pid