Add Laravel Horizon

Squashed commit of the following:

commit a079f4719f48077795abb723dc3166a14bc6debc
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 19:55:18 2017 +0100

    Update changelog

commit 97054b6ba9d2770baefd73febc6c34d38c6f1795
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 19:52:45 2017 +0100

    terminate horizon during deploy (we will once it’s running)

commit 77a4d8f0cb9faa0d05f1cf523a0b8ffbc61a2fab
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 18:47:37 2017 +0100

    type-hint the $request that is passed into the Horizon auth closure

commit 3dcddc5b1da8dd67eaf9434af73aabc07cc36a2a
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 16:31:33 2017 +0100

    This should allow us to easily access Horizon locally, and require the same auth for the /admin page for /horizon in production

commit bf65c2610e863b9ec96a921ac278702e97b9459e
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 16:11:17 2017 +0100

    Run the horizon snapshot command every five minutes

commit 428346f4170b2111f470f840ebb59b9130441817
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 15:54:59 2017 +0100

    Fix tinker

commit 2ba85e39c33b6a6febabe91a6ef7a08ffb90bfc4
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Sep 8 15:17:26 2017 +0100

    Initial install of Horizon
This commit is contained in:
Jonny Barnes 2017-09-08 20:11:38 +01:00
parent cc1e192798
commit 030740047d
16 changed files with 258 additions and 7 deletions

View file

@ -1,3 +0,0 @@
<?php
\Spatie\TinkerTools\ShortClassNames::register();

View file

@ -27,8 +27,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('horizon:snapshot')->everyFiveMinutes();
}
/**

View file

@ -0,0 +1,32 @@
<?php
namespace App\Providers;
use Laravel\Horizon\Horizon;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
class HorizonServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
Horizon::auth(function (Request $request) {
// return true/false
if (app()->environment('production') !== true) {
// we arent live so just let us into Horizon
return true;
}
if ($request->session()->has('loggedin')) {
// are we logged in as an authed user
return $request->session()->get('loggedin');
}
return false;
});
}
}

View file

@ -1,5 +1,8 @@
# Changelog
## Version {next}
- Add Laravel Horizon
## Version 0.6 (2017-09-06)
- Update laravel version to 5.5
- Improve .travis.yml and add back dusk tests

View file

@ -16,6 +16,7 @@
"jonnybarnes/indieweb": "dev-master",
"jonnybarnes/webmentions-parser": "0.4.*",
"laravel/framework": "5.5.*",
"laravel/horizon": "^1.0",
"laravel/scout": "^3.0",
"laravel/tinker": "^1.0",
"lcobucci/jwt": "^3.1",

127
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "4aa8e5b3bd31788aff471c6f0f650cd7",
"content-hash": "551d407b87a7d9ff3e65969f33605014",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -180,6 +180,63 @@
],
"time": "2016-08-19T16:43:44+00:00"
},
{
"name": "cakephp/chronos",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/cakephp/chronos.git",
"reference": "0621b191334d8dcb56907688986dd24eb8c38234"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/chronos/zipball/0621b191334d8dcb56907688986dd24eb8c38234",
"reference": "0621b191334d8dcb56907688986dd24eb8c38234",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"require-dev": {
"athletic/athletic": "~0.1",
"cakephp/cakephp-codesniffer": "~2.3",
"phpbench/phpbench": "@dev",
"phpstan/phpstan": "^0.6.4",
"phpunit/phpunit": "<6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Cake\\Chronos\\": "src"
},
"files": [
"src/carbon_compat.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Nesbitt",
"email": "brian@nesbot.com",
"homepage": "http://nesbot.com"
},
{
"name": "The CakePHP Team",
"homepage": "http://cakephp.org"
}
],
"description": "A simple API extension for DateTime.",
"homepage": "http://cakephp.org",
"keywords": [
"date",
"datetime",
"time"
],
"time": "2017-04-27T01:27:49+00:00"
},
{
"name": "cocur/slugify",
"version": "v3.0",
@ -1888,6 +1945,74 @@
],
"time": "2017-09-07T13:50:21+00:00"
},
{
"name": "laravel/horizon",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/horizon.git",
"reference": "856fe55c6d054dc063e71d97c0873013803d96df"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/856fe55c6d054dc063e71d97c0873013803d96df",
"reference": "856fe55c6d054dc063e71d97c0873013803d96df",
"shasum": ""
},
"require": {
"cakephp/chronos": "^1.0",
"ext-pcntl": "*",
"ext-posix": "*",
"illuminate/contracts": "~5.5",
"illuminate/queue": "~5.5",
"illuminate/support": "~5.5",
"php": ">=7.1.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.5",
"symfony/debug": "~3.3"
},
"require-dev": {
"mockery/mockery": "~0.9",
"orchestra/database": "~3.5",
"orchestra/testbench": "~3.5",
"phpunit/phpunit": "~6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Laravel\\Horizon\\HorizonServiceProvider"
],
"aliases": {
"Horizon": "Laravel\\Horizon\\Horizon"
}
}
},
"autoload": {
"psr-4": {
"Laravel\\Horizon\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Dashboard and code-driven configuration for Laravel queues.",
"keywords": [
"laravel",
"queue"
],
"time": "2017-09-06T19:57:45+00:00"
},
{
"name": "laravel/scout",
"version": "v3.0.7",

View file

@ -204,6 +204,7 @@ return [
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class,
/*

66
config/horizon.php Normal file
View file

@ -0,0 +1,66 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Horizon Redis Connection
|--------------------------------------------------------------------------
|
| This is the name of the Redis connection where Horizon will store the
| meta information required for it to function. It includes the list
| of supervisors, failed jobs, job metrics, and other information.
|
*/
'use' => 'default',
/*
|--------------------------------------------------------------------------
| Queue Wait Time Thresholds
|--------------------------------------------------------------------------
|
| This option allows you to configure when the LongWaitDetected event
| will be fired. Every connection / queue combination may have its
| own, unique threshold (in seconds) before this event is fired.
|
*/
'waits' => [
'redis:default' => 60,
],
/*
|--------------------------------------------------------------------------
| Queue Worker Configuration
|--------------------------------------------------------------------------
|
| Here you may define the queue worker settings used by your application
| in all environments. These supervisors and settings handle all your
| queued jobs and will be provisioned by Horizon during deployment.
|
*/
'environments' => [
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default'],
'balance' => 'simple',
'processes' => 10,
'tries' => 3,
],
],
'local' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default'],
'balance' => 'simple',
'processes' => 3,
'tries' => 3,
],
],
],
];

2
public/vendor/horizon/css/app.css vendored Normal file

File diff suppressed because one or more lines are too long

1
public/vendor/horizon/css/app.css.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"/css/app.css","sources":[],"mappings":"","sourceRoot":""}

13
public/vendor/horizon/img/horizon.svg vendored Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="226px" height="30px" viewBox="0 0 226 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 42 (36781) - http://www.bohemiancoding.com/sketch -->
<title>horizon</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="horizon" fill="#405263">
<path d="M54.132,25 L53.488,20.856 L47.552,20.856 L47.552,5.68 L42.764,5.68 L42.764,25 L54.132,25 Z M67.432,25 L63.68,25 L63.4,23.292 C62.28,24.468 60.964,25.28 59.088,25.28 C56.904,25.28 55.364,23.964 55.364,21.472 C55.364,18.252 57.828,16.74 63.204,16.264 L63.204,16.012 C63.204,14.808 62.532,14.276 61.132,14.276 C59.592,14.276 58.164,14.668 56.708,15.312 L56.204,12.12 C57.772,11.476 59.536,11.056 61.776,11.056 C65.556,11.056 67.432,12.316 67.432,15.816 L67.432,25 Z M63.204,21.22 L63.204,18.308 C60.32,18.756 59.536,19.708 59.536,20.912 C59.536,21.78 60.068,22.256 60.852,22.256 C61.664,22.256 62.448,21.892 63.204,21.22 Z M79.08,15.312 L78.38,11 C76.364,11.14 75.216,12.428 74.376,13.996 L73.928,11.28 L70.232,11.28 L70.232,25 L74.46,25 L74.46,17.384 C75.496,16.264 77.036,15.452 79.08,15.312 Z M92.184,25 L88.432,25 L88.152,23.292 C87.032,24.468 85.716,25.28 83.84,25.28 C81.656,25.28 80.116,23.964 80.116,21.472 C80.116,18.252 82.58,16.74 87.956,16.264 L87.956,16.012 C87.956,14.808 87.284,14.276 85.884,14.276 C84.344,14.276 82.916,14.668 81.46,15.312 L80.956,12.12 C82.524,11.476 84.288,11.056 86.528,11.056 C90.308,11.056 92.184,12.316 92.184,15.816 L92.184,25 Z M87.956,21.22 L87.956,18.308 C85.072,18.756 84.288,19.708 84.288,20.912 C84.288,21.78 84.82,22.256 85.604,22.256 C86.416,22.256 87.2,21.892 87.956,21.22 Z M107.5,11.28 L103.384,11.28 L100.892,19.764 L98.344,11.084 L93.808,11.616 L98.484,25.056 L102.712,25.056 L107.5,11.28 Z M121.052,18.112 C121.052,18.532 121.024,18.98 120.968,19.204 L112.736,19.204 C112.96,21.36 114.248,22.2 116.096,22.2 C117.608,22.2 119.092,21.64 120.604,20.772 L121.024,23.74 C119.54,24.692 117.72,25.28 115.564,25.28 C111.448,25.28 108.508,23.096 108.508,18.196 C108.508,13.716 111.252,11 114.976,11 C119.176,11 121.052,14.136 121.052,18.112 Z M117.02,16.88 C116.88,14.808 116.152,13.744 114.864,13.744 C113.688,13.744 112.848,14.78 112.708,16.88 L117.02,16.88 Z M127.66,25 L127.66,4.784 L123.404,5.456 L123.404,25 L127.66,25 Z M152.692,25 L152.692,5.68 L150.76,5.68 L150.76,14.024 L140.036,14.024 L140.036,5.68 L138.104,5.68 L138.104,25 L140.036,25 L140.036,15.76 L150.76,15.76 L150.76,25 L152.692,25 Z M168.568,18.392 C168.568,22.76 165.936,25.28 162.548,25.28 C159.16,25.28 156.612,22.76 156.612,18.392 C156.612,13.996 159.216,11.476 162.548,11.476 C165.992,11.476 168.568,13.996 168.568,18.392 Z M166.664,18.392 C166.664,15.34 165.208,13.044 162.548,13.044 C159.916,13.044 158.488,15.256 158.488,18.392 C158.488,21.444 159.944,23.712 162.548,23.712 C165.236,23.712 166.664,21.528 166.664,18.392 Z M178.872,13.212 L178.564,11.476 C176.38,11.532 174.84,12.988 173.86,14.472 L173.44,11.756 L172.068,11.756 L172.068,25 L173.916,25 L173.916,16.684 C174.812,14.92 176.688,13.352 178.872,13.212 Z M184.136,7.248 C184.136,6.52 183.548,5.904 182.82,5.904 C182.092,5.904 181.476,6.52 181.476,7.248 C181.476,7.976 182.092,8.592 182.82,8.592 C183.548,8.592 184.136,7.976 184.136,7.248 Z M183.716,25 L183.716,11.756 L181.896,11.756 L181.896,25 L183.716,25 Z M197.464,25 L197.212,23.46 L189.344,23.46 L197.24,13.184 L197.24,11.756 L187.636,11.756 L187.888,13.296 L195.112,13.296 L187.216,23.572 L187.216,25 L197.464,25 Z M211.94,18.392 C211.94,22.76 209.308,25.28 205.92,25.28 C202.532,25.28 199.984,22.76 199.984,18.392 C199.984,13.996 202.588,11.476 205.92,11.476 C209.364,11.476 211.94,13.996 211.94,18.392 Z M210.036,18.392 C210.036,15.34 208.58,13.044 205.92,13.044 C203.288,13.044 201.86,15.256 201.86,18.392 C201.86,21.444 203.316,23.712 205.92,23.712 C208.608,23.712 210.036,21.528 210.036,18.392 Z M225.884,25 L225.884,15.536 C225.884,12.988 224.568,11.476 221.936,11.476 C220.144,11.476 218.632,12.428 217.176,13.716 L216.868,11.756 L215.44,11.756 L215.44,25 L217.288,25 L217.288,15.424 C218.744,13.996 220.172,13.128 221.572,13.128 C223.252,13.128 224.036,14.164 224.036,15.872 L224.036,25 L225.884,25 Z" id="Laravel-Horizon"></path>
<path d="M5.26176342,26.4094389 C2.04147988,23.6582233 0,19.5675182 0,15 C0,10.8578644 1.67893219,7.10786438 4.39339828,4.39339828 C7.10786438,1.67893219 10.8578644,0 15,0 C23.2842712,3.55271368e-15 30,6.71572875 30,15 C30,23.2842712 23.2842712,30 15,30 C11.283247,30 7.88222338,28.6482016 5.26176342,26.4094389 L5.26176342,26.4094389 Z M4.03811305,15.9222506 C5.70084247,14.4569342 6.87195416,12.5 10,12.5 C15,12.5 15,17.5 20,17.5 C23.1280454,17.5 24.2991572,15.5430664 25.961887,14.0777498 C25.4934253,8.43417206 20.7645408,4 15,4 C8.92486775,4 4,8.92486775 4,15 C4,15.3105915 4.01287248,15.6181765 4.03811305,15.9222506 L4.03811305,15.9222506 Z" id="Combined-Shape" fill-rule="nonzero"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5 KiB

1
public/vendor/horizon/img/sprite.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 55 KiB

2
public/vendor/horizon/js/app.js vendored Normal file

File diff suppressed because one or more lines are too long

1
public/vendor/horizon/js/app.js.map vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,6 @@
{
"/js/app.js": "/js/app.js?id=9bd1f62368806951d0da",
"/css/app.css": "/css/app.css?id=1f235151e78555d1e034",
"/js/app.js.map": "/js/app.js.map?id=f979e94a4ab33a650101",
"/css/app.css.map": "/css/app.css.map?id=e763cea28ae63fce4ad5"
}

View file

@ -2,6 +2,7 @@
echo "Putting the Laravel app in maintenance mode"
php artisan down
#php artisan horizon:terminate
echo "Pulling the latest changes"
git pull
@ -14,7 +15,7 @@ echo "Caching Laravel route and config files"
php artisan route:cache
php artisan config:cache
echo "Restarting the queue daemon"
echo "Restarting the supervisord instances"
sudo supervisorctl restart all
echo "Bringing the Laravel app back online"