morozovsk\websocket\Server::stop PHP Method

stop() public method

for ($i=0; $i<$this->config['master']['workers']; $i++) { create a pair of sockets through which the master and the worker is to be linked $pair = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP); $pid = pcntl_fork();//create a fork if ($pid == -1) { die("error: pcntl_fork\r\n"); } elseif ($pid) { //master fclose($pair[0]); $workers[intval($pair[1])] = $pair[1];//one of the pair is in the master } else { //worker fclose($pair[1]); $master = $pair[0];//second of pair is in worker break; } } return array($pid, $master, $workers); }
public stop ( )
    public function stop()
    {
        $pid = @file_get_contents($this->config['pid']);
        if ($pid) {
            posix_kill($pid, SIGTERM);
            for ($i = 0; $i = 10; $i++) {
                sleep(1);
                if (!posix_getpgid($pid)) {
                    unlink($this->config['pid']);
                    return;
                }
            }
            die("don't stopped\r\n");
        } else {
            die("already stopped\r\n");
        }
    }