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