AppserverIo\Appserver\Application\Application::stop PHP Method

stop() public method

Stops the application instance.
public stop ( ) : void
return void
    public function stop()
    {
        // start application shutdown
        $this->synchronized(function ($self) {
            $self->applicationState = ApplicationStateKeys::get(ApplicationStateKeys::HALT);
        }, $this);
        do {
            // log a message that we'll wait till application has been shutdown
            $this->getInitialContext()->getSystemLogger()->info(sprintf('Wait for application %s to be shutdown', $this->getName()));
            // query whether application state key is SHUTDOWN or not
            $waitForShutdown = $this->synchronized(function ($self) {
                return $self->applicationState->notEquals(ApplicationStateKeys::get(ApplicationStateKeys::SHUTDOWN));
            }, $this);
            // wait one second more
            sleep(1);
        } while ($waitForShutdown);
    }