mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-24 06:28:27 +01:00
Added in support for custom healthchecks server
This commit is contained in:
@@ -52,19 +52,19 @@ class SpeedtestJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if($this->config['healthchecks_enabled'] === true) {
|
if ($this->config['healthchecks_enabled'] === true) {
|
||||||
$this->healthcheck('start');
|
$this->healthcheck('start');
|
||||||
}
|
}
|
||||||
$output = SpeedtestHelper::output();
|
$output = SpeedtestHelper::output();
|
||||||
$speedtest = SpeedtestHelper::runSpeedtest($output, $this->scheduled);
|
$speedtest = SpeedtestHelper::runSpeedtest($output, $this->scheduled);
|
||||||
if($speedtest == false) {
|
if ($speedtest == false) {
|
||||||
if($this->config['healthchecks_enabled'] === true) {
|
if ($this->config['healthchecks_enabled'] === true) {
|
||||||
$this->healthcheck('fail');
|
$this->healthcheck('fail');
|
||||||
}
|
}
|
||||||
|
|
||||||
event(new SpeedtestFailedEvent());
|
event(new SpeedtestFailedEvent());
|
||||||
} else {
|
} else {
|
||||||
if($this->config['healthchecks_enabled'] === true) {
|
if ($this->config['healthchecks_enabled'] === true) {
|
||||||
$this->healthcheck('success');
|
$this->healthcheck('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,19 +82,19 @@ class SpeedtestJob implements ShouldQueue
|
|||||||
private function healthcheck(String $method)
|
private function healthcheck(String $method)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$hc = new Healthchecks(SettingsHelper::get('healthchecks_uuid')->value);
|
$hc = new Healthchecks(SettingsHelper::get('healthchecks_uuid')->value, SettingsHelper::get('healthchecks_server_url')->value);
|
||||||
if($method === 'start') {
|
if ($method === 'start') {
|
||||||
$hc->start();
|
$hc->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($method === 'success') {
|
if ($method === 'success') {
|
||||||
$hc->success();
|
$hc->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($method === 'fail') {
|
if ($method === 'fail') {
|
||||||
$hc->fail();
|
$hc->fail();
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class IntegrationsServiceProvider extends ServiceProvider
|
|||||||
SettingsHelper::loadIntegrationConfig();
|
SettingsHelper::loadIntegrationConfig();
|
||||||
|
|
||||||
App::bind('healthcheck', function () use ($setting) {
|
App::bind('healthcheck', function () use ($setting) {
|
||||||
return new Healthchecks($setting->value);
|
return new Healthchecks($setting->value, SettingsHelper::get('healthchecks_server_url')->value);
|
||||||
});
|
});
|
||||||
} catch (InvalidUuidStringException $e) {
|
} catch (InvalidUuidStringException $e) {
|
||||||
Log::error('Invalid healthchecks UUID');
|
Log::error('Invalid healthchecks UUID');
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Helpers\SettingsHelper;
|
||||||
|
use App\Setting;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddCustomHealthchecksSetting extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (!SettingsHelper::get('healthchecks_server_url')) {
|
||||||
|
Setting::create([
|
||||||
|
'name' => 'healthchecks_server_url',
|
||||||
|
'value' => 'https://hc-ping.com/',
|
||||||
|
'description' => 'The URL of the healthchecks.io server. Change this to use a self-hosted server.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Setting::whereIn('name', [
|
||||||
|
'healthchecks_server_url',
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
6
public/js/app.js
vendored
6
public/js/app.js
vendored
@@ -140866,6 +140866,9 @@ var SettingsIndex = /*#__PURE__*/function (_Component) {
|
|||||||
General: [{
|
General: [{
|
||||||
obj: data.app_name,
|
obj: data.app_name,
|
||||||
type: 'text'
|
type: 'text'
|
||||||
|
}, {
|
||||||
|
obj: data.schedule_enabled,
|
||||||
|
type: 'text'
|
||||||
}, {
|
}, {
|
||||||
obj: data.schedule,
|
obj: data.schedule,
|
||||||
type: 'text'
|
type: 'text'
|
||||||
@@ -140979,6 +140982,9 @@ var SettingsIndex = /*#__PURE__*/function (_Component) {
|
|||||||
healthchecks: [{
|
healthchecks: [{
|
||||||
obj: data.healthchecks_enabled,
|
obj: data.healthchecks_enabled,
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
|
}, {
|
||||||
|
obj: data.healthchecks_server_url,
|
||||||
|
type: 'text'
|
||||||
}, {
|
}, {
|
||||||
obj: data.healthchecks_uuid,
|
obj: data.healthchecks_uuid,
|
||||||
type: 'text'
|
type: 'text'
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ export default class SettingsIndex extends Component {
|
|||||||
obj: data.app_name,
|
obj: data.app_name,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
obj: data.schedule_enabled,
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
obj: data.schedule,
|
obj: data.schedule,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -188,6 +192,10 @@ export default class SettingsIndex extends Component {
|
|||||||
obj: data.healthchecks_enabled,
|
obj: data.healthchecks_enabled,
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
obj: data.healthchecks_server_url,
|
||||||
|
type: 'text'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
obj: data.healthchecks_uuid,
|
obj: data.healthchecks_uuid,
|
||||||
type: 'text'
|
type: 'text'
|
||||||
|
|||||||
Reference in New Issue
Block a user