1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\UptimeMonitor; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Spatie\UptimeMonitor\Commands\CheckCertificates; |
7
|
|
|
use Spatie\UptimeMonitor\Commands\CheckUptime; |
8
|
|
|
use Spatie\UptimeMonitor\Commands\CreateMonitor; |
9
|
|
|
use Spatie\UptimeMonitor\Commands\DeleteMonitor; |
10
|
|
|
use Spatie\UptimeMonitor\Commands\DisableMonitor; |
11
|
|
|
use Spatie\UptimeMonitor\Commands\EnableMonitor; |
12
|
|
|
use Spatie\UptimeMonitor\Commands\ListMonitors; |
13
|
|
|
use Spatie\UptimeMonitor\Helpers\UptimeResponseCheckers\UptimeResponseChecker; |
14
|
|
|
use Spatie\UptimeMonitor\Notifications\EventHandler; |
15
|
|
|
|
16
|
|
|
class UptimeMonitorServiceProvider extends ServiceProvider |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Bootstrap the application services. |
20
|
|
|
*/ |
21
|
|
|
public function boot() |
22
|
|
|
{ |
23
|
|
|
if ($this->app->runningInConsole()) { |
24
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
25
|
|
|
|
26
|
|
|
$this->publishes([ |
27
|
|
|
__DIR__ . '/../config/laravel-uptime-monitor.php' => config_path('laravel-uptime-monitor.php'), |
28
|
|
|
], 'config'); |
29
|
|
|
} else { |
30
|
|
|
if (config('laravel-uptime-monitor.restAPI.enable')) { |
31
|
|
|
$this->loadRoutesFrom(__DIR__ . '/Http/routes.php'); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if (!class_exists('CreateSitesTable')) { |
36
|
|
|
$timestamp = date('Y_m_d_His', time()); |
37
|
|
|
|
38
|
|
|
$this->publishes([ |
39
|
|
|
__DIR__ . '/../database/migrations/create_monitors_table.php.stub' => database_path('migrations/' . $timestamp . '_create_monitors_table.php'), |
40
|
|
|
], 'migrations'); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Register the application services. |
46
|
|
|
*/ |
47
|
|
|
public function register() |
48
|
|
|
{ |
49
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../config/laravel-uptime-monitor.php', 'laravel-uptime-monitor'); |
50
|
|
|
|
51
|
|
|
$this->app['events']->subscribe(EventHandler::class); |
52
|
|
|
|
53
|
|
|
$this->app->bind('command.monitor:check-uptime', CheckUptime::class); |
54
|
|
|
$this->app->bind('command.monitor:check-certificate', CheckCertificates::class); |
55
|
|
|
$this->app->bind('command.monitor:create', CreateMonitor::class); |
56
|
|
|
$this->app->bind('command.monitor:delete', DeleteMonitor::class); |
57
|
|
|
$this->app->bind('command.monitor:enable', EnableMonitor::class); |
58
|
|
|
$this->app->bind('command.monitor:disable', DisableMonitor::class); |
59
|
|
|
$this->app->bind('command.monitor:list', ListMonitors::class); |
60
|
|
|
|
61
|
|
|
$this->app->bind( |
62
|
|
|
UptimeResponseChecker::class, |
63
|
|
|
config('laravel-uptime-monitor.uptime_check.response_checker') |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
$this->commands([ |
67
|
|
|
'command.monitor:check-uptime', |
68
|
|
|
'command.monitor:check-certificate', |
69
|
|
|
'command.monitor:create', |
70
|
|
|
'command.monitor:delete', |
71
|
|
|
'command.monitor:enable', |
72
|
|
|
'command.monitor:disable', |
73
|
|
|
'command.monitor:list', |
74
|
|
|
]); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|