Created
February 18, 2019 10:48
-
-
Save sgasser/59a2ee17df0c099ca147e1fc7f1bb51d to your computer and use it in GitHub Desktop.
SchedulerDaemon.php for Heroku Laravel Scheduler
This file contains hidden or 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 App\Console\Commands; | |
| use Illuminate\Console\Command; | |
| /** | |
| * Runs the scheduler every 60 seconds as expected to be done by cron. | |
| */ | |
| class SchedulerDaemon extends Command | |
| { | |
| /** | |
| * The name and signature of the console command. | |
| * | |
| * @var string | |
| */ | |
| protected $signature = 'schedule:daemon {--sleep=60}'; | |
| /** | |
| * The console command description. | |
| * | |
| * @var string | |
| */ | |
| protected $description = 'Call the scheduler every minute.'; | |
| /** | |
| * Execute the console command. | |
| * | |
| * @return mixed | |
| */ | |
| public function handle() | |
| { | |
| while (true) { | |
| $this->info('Calling scheduler'); | |
| $this->call('schedule:run'); | |
| sleep($this->option('sleep')); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment