protected function shutdown($restart = false)
    {
        // If we are already exiting, chill.
        if ($this->exiting) {
            return;
        } else // If not, now we are.
        {
            $this->exiting = true;
        }

        // If we aren't already daemonized then just kill the application.
        if (!$this->running && !$this->isActive()) {
            $this->getLogger()->info('Process was not daemonized yet, just halting current process');

            $this->close();
        }

        // Only read the pid for the parent file.
        if ($this->parentId == $this->processId) {
            // Read the contents of the process id file as an integer.
            $fp = fopen($this->config->get('application_pid_file'), 'r');
            $pid = fread($fp, filesize($this->config->get('application_pid_file')));
            $pid = (int) $pid;
            fclose($fp);

            // Remove the process id file.
            @ unlink($this->config->get('application_pid_file'));

            // If we are supposed to restart the daemon we need to execute the same command.
            if ($restart) {
                $this->close(exec(implode(' ', $GLOBALS['argv']) . ' > /dev/null &'));
            } else // If we are not supposed to restart the daemon let's just kill -9.
            {
                passthru('kill -9 ' . $pid);
                $this->close();
            }
        }
    }
protected function shutdown($restart = false)
    {
        // If we are already exiting, chill.
        if ($this->exiting) {
            return;
        } else // If not, now we are.
        {
            $this->exiting = true;
        }

        // If we aren't already daemonized then just kill the application.
        if (!$this->running && !$this->isActive()) {
            $this->getLogger()->info('Process was not daemonized yet, just halting current process');

            $this->close();
        }

        // Only read the pid for the parent file.
        if ($this->parentId == $this->processId) {
            // Read the contents of the process id file as an integer.
            $fp = fopen($this->config->get('application_pid_file'), 'r');
            $pid = fread($fp, filesize($this->config->get('application_pid_file')));
            $pid = (int) $pid;
            fclose($fp);

            // Remove the process id file.
            @ unlink($this->config->get('application_pid_file'));

            // If we are supposed to restart the daemon we need to execute the same command.
            if ($restart) {
                $this->close(exec(implode(' ', $GLOBALS['argv']) . ' > /dev/null &'));
            } else // If we are not supposed to restart the daemon let's just kill -9.
            {
                passthru('kill -9 ' . $pid);
                $this->close();
            }
        }
    }
protected function shutdown ( $ restart = false ) { // If we are already exiting, chill. if ( $ this -> exiting ) { return ; } else // If not, now we are. { $ this -> exiting = true ; } // If we aren't already daemonized then just kill the application. if ( ! $ this -> running && ! $ this -> isActive ( ) ) { $ this -> getLogger ( ) -> info ( 'Process was not daemonized yet, just halting current process' ) ; $ this -> close ( ) ; } // Only read the pid for the parent file. if ( $ this -> parentId == $ this -> processId ) { // Read the contents of the process id file as an integer. $ fp = fopen ( $ this -> config -> get ( 'application_pid_file' ) , 'r' ) ; $ pid = fread ( $ fp , filesize ( $ this -> config -> get ( 'application_pid_file' ) ) ) ; $ pid = ( int ) $ pid ; fclose ( $ fp ) ; // Remove the process id file. @ unlink ( $ this -> config -> get ( 'application_pid_file' ) ) ; // If we are supposed to restart the daemon we need to execute the same command. if ( $ restart ) { $ this -> close ( exec ( implode ( ' ' , $ GLOBALS [ 'argv' ] ) . ' > /dev/null &' ) ) ; } else // If we are not supposed to restart the daemon let's just kill -9. { passthru ( 'kill -9 ' . $ pid ) ; $ this -> close ( ) ; } } }
Method to shut down the daemon and optionally restart it.

@param   boolean $restart True to restart the daemon on exit.

@return  void

@since   2.0
Method to shut down the daemon and optionally restart it .