1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ProtoneMedia\ApiHealth; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Event; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use ProtoneMedia\ApiHealth\Console\Check; |
8
|
|
|
use ProtoneMedia\ApiHealth\Console\MakeChecker; |
9
|
|
|
use ProtoneMedia\ApiHealth\Console\MakeHttpChecker; |
10
|
|
|
use ProtoneMedia\ApiHealth\Console\MakeSslCertificateChecker; |
11
|
|
|
use ProtoneMedia\ApiHealth\Console\RunCheckers; |
12
|
|
|
use ProtoneMedia\ApiHealth\Events\CheckerHasFailed; |
13
|
|
|
use ProtoneMedia\ApiHealth\Events\CheckerHasRecovered; |
14
|
|
|
use ProtoneMedia\ApiHealth\Events\CheckerIsStillFailing; |
15
|
|
|
use ProtoneMedia\ApiHealth\Listeners\SendFailedNotification; |
16
|
|
|
use ProtoneMedia\ApiHealth\Listeners\SendRecoveredNotification; |
17
|
|
|
|
18
|
|
|
class ApiHealthServiceProvider extends ServiceProvider |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Bootstrap the application services. |
22
|
|
|
*/ |
23
|
|
|
public function boot() |
24
|
|
|
{ |
25
|
|
|
$this->publishes([ |
26
|
|
|
__DIR__ . '/../config/api-health.php' => config_path('api-health.php'), |
27
|
|
|
], 'config'); |
28
|
|
|
|
29
|
|
|
$this->publishes([ |
30
|
|
|
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/api-health'), |
31
|
|
|
]); |
32
|
|
|
|
33
|
|
|
$this->loadTranslationsFrom( |
34
|
|
|
__DIR__ . '/../resources/lang/', |
35
|
|
|
'api-health' |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
Event::listen(CheckerHasFailed::class, SendFailedNotification::class); |
39
|
|
|
Event::listen(CheckerIsStillFailing::class, SendFailedNotification::class); |
40
|
|
|
Event::listen(CheckerHasRecovered::class, SendRecoveredNotification::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Register the application services. |
45
|
|
|
*/ |
46
|
|
|
public function register() |
47
|
|
|
{ |
48
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../config/api-health.php', 'api-health'); |
49
|
|
|
|
50
|
|
|
$this->app->bind('command.api-health:check', Check::class); |
51
|
|
|
$this->app->bind('command.api-health:run-checkers', RunCheckers::class); |
52
|
|
|
$this->app->bind('command.make:checker', MakeChecker::class); |
53
|
|
|
$this->app->bind('command.make:http-checker', MakeHttpChecker::class); |
54
|
|
|
$this->app->bind('command.make:ssl-certificate-checker', MakeSslCertificateChecker::class); |
55
|
|
|
|
56
|
|
|
$this->commands([ |
57
|
|
|
'command.api-health:check', |
58
|
|
|
'command.api-health:run-checkers', |
59
|
|
|
'command.make:checker', |
60
|
|
|
'command.make:http-checker', |
61
|
|
|
'command.make:ssl-certificate-checker', |
62
|
|
|
]); |
63
|
|
|
|
64
|
|
|
$this->app->singleton('laravel-api-health', function ($app) { |
65
|
|
|
return $app->make(ApiHealthChecker::class); |
66
|
|
|
}); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|