-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSupervisorServiceProvider.php
37 lines (29 loc) · 1.14 KB
/
SupervisorServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace RalphJSmit\LaravelHorizonCron\Supervisor;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\ServiceProvider;
class SupervisorServiceProvider extends ServiceProvider
{
public function boot(): void
{
$this->publishes([
__DIR__ . '/../../config/horizon-cron-supervisor.php' => config_path('horizon-cron-supervisor.php'),
], 'horizon-cron-supervisor-config');
$this->commands([
\RalphJSmit\LaravelHorizonCron\Supervisor\Console\RestartHorizon::class,
]);
$this->app->booted(function () {
if (config('horizon-cron-supervisor.enabled')) {
$schedule = $this->app->make(Schedule::class);
$expression = config('horizon-cron-supervisor.schedule');
$schedule
->command('supervisor:check')
->cron(is_numeric($expression) ? "*/{$expression} * * * *" : $expression);
}
});
}
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../../config/horizon-cron-supervisor.php', 'horizon-cron-supervisor');
}
}