private function doConnect()
    {
        $connector = new UnixConnector($this->loop);
        $unixSocket = $this->getControllerSocketPath(false);

        $connector->connect($unixSocket)->done(
            function ($controller) {
                $this->controller = $controller;

                $this->loop->addSignal(SIGTERM, [$this, 'shutdown']);
                $this->loop->addSignal(SIGINT, [$this, 'shutdown']);
                register_shutdown_function([$this, 'prepareShutdown']);

                $this->bindProcessMessage($this->controller);
                $this->controller->on('close', [$this, 'shutdown']);

                // port is the slave identifier
                $port = $this->config['port'];
                $socketPath = $this->getSlaveSocketPath($port, true);
                $this->server = new UnixServer($socketPath, $this->loop);

                $httpServer = new HttpServer([$this, 'onRequest']);
                $httpServer->listen($this->server);

                $this->sendMessage($this->controller, 'register', ['pid' => getmypid(), 'port' => $port]);
            }
        );
    }