StackFormation\Observer::observeStackActivity PHP Method

observeStackActivity() public method

public observeStackActivity ( $pollInterval = 20 )
    public function observeStackActivity($pollInterval = 20)
    {
        $eventTable = new StackEventsTable($this->output);
        $lastStatus = Poller::poll(function () use($eventTable) {
            try {
                try {
                    $this->stack = $this->stackFactory->getStack($this->stack->getName(), true);
                    // load fresh instance for updated status
                    $this->output->writeln("-> Polling... (Stack Status: {$this->stack->getStatus()})");
                    $eventTable->renderEvents($this->stack->getEvents());
                } catch (CloudFormationException $exception) {
                    throw Exception::refineException($exception);
                }
            } catch (StackNotFoundException $exception) {
                $this->output->writeln("-> Stack gone.");
                return Stack::STATUS_STACK_GONE;
                // this is != false and will stop the poller
            }
            return $this->stack->isInProgress() ? false : $this->stack->getStatus();
        }, $pollInterval, 1000);
        $this->printStatus($lastStatus);
        $this->printResources();
        $this->printOutputs();
        return $lastStatus;
    }

Usage Example

 protected function executeWithStack(Stack $stack, InputInterface $input, OutputInterface $output)
 {
     $observer = new Observer($stack, $this->getStackFactory(), $output);
     if ($input->getOption('deleteOnTerminate')) {
         $observer->deleteOnSignal();
     }
     return $observer->observeStackActivity();
 }
All Usage Examples Of StackFormation\Observer::observeStackActivity