-
-
Save 3m1n3nc3/f9188880a64e43ee19bb1d8da14b425d to your computer and use it in GitHub Desktop.
Laravel 5 Database Queue - Shared Hosting
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
/usr/bin/php /path/to/artisan schedule:run >/dev/null 2>&1 |
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; | |
use Illuminate\Console\Scheduling\Schedule; | |
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | |
class Kernel extends ConsoleKernel | |
{ | |
/** | |
* The Artisan commands provided by your application. | |
* | |
* @var array | |
*/ | |
protected $commands = [ | |
]; | |
/** | |
* Define the application's command schedule. | |
* | |
* @param \Illuminate\Console\Scheduling\Schedule $schedule | |
* @return void | |
*/ | |
protected function schedule(Schedule $schedule) | |
{ | |
$path = base_path(); | |
$schedule->call(function() use($path) { | |
if (file_exists($path . '/queue.pid')) { | |
$pid = file_get_contents($path . '/queue.pid'); | |
$result = exec("ps -p $pid --no-heading | awk '{print $1}'"); | |
$run = $result == '' ? true : false; | |
} else { | |
$run = true; | |
} | |
if($run) { | |
$command = '/usr/bin/php -c ' . $path .'/php.ini ' . $path . '/artisan queue:listen --tries=3 > /dev/null & echo $!'; | |
$number = exec($command); | |
file_put_contents($path . '/queue.pid', $number); | |
} | |
})->name('monitor_queue_listener')->everyFiveMinutes(); | |
} | |
} |
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
register_argc_argv=On |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment