Skip to content

Commit

Permalink
πŸ”¨ WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Melbourne committed Aug 19, 2019
1 parent 6d90db7 commit 2546911
Show file tree
Hide file tree
Showing 22 changed files with 1,496 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

HORIZON_ENABLED=false
42 changes: 42 additions & 0 deletions app/Console/Commands/ScanCertificateCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class ScanCertificateCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
42 changes: 42 additions & 0 deletions app/Console/Commands/ScanDnsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class ScanDnsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
59 changes: 59 additions & 0 deletions app/Console/Commands/ScanEverythingCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Console\Commands;

use App\Website;
use App\Jobs\DnsCheck;
use App\Jobs\RobotsCheck;
use App\Jobs\UptimeCheck;
use App\Checkers\Certificate;
use App\Jobs\CertificateCheck;
use Illuminate\Console\Command;

class ScanEverythingCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'scan:everything';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Website::all()->each(function (Website $website) {
dump('Running monitors for ' . $website->url);
CertificateCheck::dispatch($website);
dump('Certificate check queued.');
RobotsCheck::dispatch($website);
dump('Robots check queued.');
UptimeCheck::dispatch($website);
dump('Uptime check queued.');
DnsCheck::dispatch($website);
dump('DNS check queued.');
echo PHP_EOL;
});
}
}
42 changes: 42 additions & 0 deletions app/Console/Commands/ScanRobotsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class ScanRobotsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
42 changes: 42 additions & 0 deletions app/Console/Commands/ScanUptimeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class ScanUptimeCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
11 changes: 9 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class Kernel extends ConsoleKernel
//
];

protected function scheduleTimezone()
{
return 'Europe/London';
}

/**
* Define the application's command schedule.
*
Expand All @@ -24,8 +29,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('scan:uptime')->everyFiveMinutes()->withoutOverlapping()->runInBackground();
$schedule->command('scan:robots')->hourly()->withoutOverlapping()->runInBackground();
$schedule->command('scan:dns')->hourly()->withoutOverlapping()->runInBackground();
$schedule->command('scan:certificate')->dailyAt('08:00:00')->withoutOverlapping()->runInBackground();
}

/**
Expand Down
40 changes: 40 additions & 0 deletions app/Providers/HorizonServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Providers;

use Laravel\Horizon\Horizon;
use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\HorizonApplicationServiceProvider;

class HorizonServiceProvider extends HorizonApplicationServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();

// Horizon::routeSmsNotificationsTo('15556667777');
// Horizon::routeMailNotificationsTo('[email protected]');
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');

// Horizon::night();
}

/**
* Register the Horizon gate.
*
* This gate determines who can access Horizon in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewHorizon', function () {
return config('horizon.enabled', false);
});
}
}
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.8.*",
"laravel/horizon": "^3.3",
"laravel/tinker": "^1.0",
"maelstrom-cms/toolkit": "^1.0",
"predis/predis": "^1.1",
"sebastian/diff": "^3.0",
"spatie/ssl-certificate": "^1.15",
"visualappeal/php-ssllabs-api": "^1.0",
Expand Down
Loading

0 comments on commit 2546911

Please sign in to comment.