Skip to content

Instantly share code, notes, and snippets.

@sgasser
Created February 18, 2019 10:48
Show Gist options
  • Select an option

  • Save sgasser/59a2ee17df0c099ca147e1fc7f1bb51d to your computer and use it in GitHub Desktop.

Select an option

Save sgasser/59a2ee17df0c099ca147e1fc7f1bb51d to your computer and use it in GitHub Desktop.
SchedulerDaemon.php for Heroku Laravel Scheduler
<?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