Created
March 4, 2016 17:08
-
-
Save sandvige/e149d04fe3020275889d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace XXX\XXX\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Bundle\SwiftmailerBundle\Command\SendEmailCommand as OriginalSendEmailCommand; | |
class SendEmailCommand extends OriginalSendEmailCommand | |
{ | |
/** | |
* @see Command | |
*/ | |
protected function configure() | |
{ | |
parent::configure(); | |
$this | |
->setName('xxx:spool:send') | |
->setDescription('Sends emails from the spool repeatedly') | |
->addOption('waiting-time', null, InputOption::VALUE_OPTIONAL, 'Time to wait between two calls', 1000) | |
; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
while (true) { | |
parent::execute($input, $output); | |
usleep($input->getOption('waiting-time') * 1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This crontab ensures the infinite loop is always running. Start it if it's not, do nothing if the pid file is valid.