setDescription('Heartbeat connection to track drops or broken pipes') ->addOption('heartbeat', null, InputOption::VALUE_REQUIRED, sprintf('in seconds (default: %d)', self::DEFAULT_INTERVAL)) ; return $this; } protected function doExecute(InputInterface $input, OutputInterface $output) { /** @var AMQPConnection $serverConnection */ $serverConnection = $this->container['alchemy_worker.amqp.connection']; $connection = $serverConnection->getConnection(); $interval = $input->getOption('heartbeat'); if (empty($interval)) { $interval = self::DEFAULT_INTERVAL; } $heartbeatHandler = new HeartbeatHandler($connection); $heartbeatHandler->run($interval); return 0; } }