From 7c403540ee65134bc236607fb17f506c40c25fb8 Mon Sep 17 00:00:00 2001 From: Wouter Koppenol Date: Fri, 12 Jun 2020 00:29:46 +0200 Subject: [PATCH] #241 All horizon environments now have their separate queues so they won't cannibalize another environment's jobs. --- app/Console/Kernel.php | 7 ++----- app/Logic/Scheduler/FindOutdatedThumbnails.php | 4 ++-- composer.json | 2 +- config/horizon.php | 8 ++++---- docs/lua.md | 2 +- docs/scheduler.md | 6 ++++++ resources/views/admin/tools/mdt/string.blade.php | 2 +- resources/views/layouts/app.blade.php | 2 +- sh/setup_lua.sh | 6 ++++-- 9 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 docs/scheduler.md diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3f8288293..72544dcd5 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -27,13 +27,10 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - Log::channel('scheduler')->debug("Starting scheduler"); - - // $schedule->command('inspire') - // ->hourly(); + Log::channel('scheduler')->debug('Starting scheduler'); $schedule->call(new FindOutdatedThumbnails)->everyFiveMinutes(); $schedule->call(new DeleteExpiredDungeonRoutes)->hourly(); - Log::channel('scheduler')->debug("Finished scheduler"); + Log::channel('scheduler')->debug('Finished scheduler'); } /** diff --git a/app/Logic/Scheduler/FindOutdatedThumbnails.php b/app/Logic/Scheduler/FindOutdatedThumbnails.php index 752ef6cac..05ba5e57e 100644 --- a/app/Logic/Scheduler/FindOutdatedThumbnails.php +++ b/app/Logic/Scheduler/FindOutdatedThumbnails.php @@ -47,10 +47,10 @@ function __invoke() ((// Updated at is greater than the thumbnail updated at (don't keep updating thumbnails..) $updatedAt->greaterThan($thumbnailUpdatedAt) && // If the route has been updated in the past x minutes... - $updatedAt->addMinute(config('keystoneguru.thumbnail_refresh_min'))->isPast()) + $updatedAt->addMinutes(config('keystoneguru.thumbnail_refresh_min'))->isPast()) || // Update every month regardless - $thumbnailUpdatedAt->addMonth(1)->isPast() + $thumbnailUpdatedAt->addMonth()->isPast() || // Thumbnail does not exist in the folder it should !ProcessRouteFloorThumbnail::thumbnailsExistsForRoute($dungeonRoute) diff --git a/composer.json b/composer.json index 3da4cff5b..c55d22d0e 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } ], "require": { - "php": ">=5.6.4", + "php": ">=7.4", "ext-json": "*", "barryvdh/laravel-ide-helper": "^2.4", "folklore/image": "0.3.*", diff --git a/config/horizon.php b/config/horizon.php index e4930a4a4..09c646ad9 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -142,14 +142,14 @@ 'production' => [ 'supervisor-default' => [ 'connection' => 'redis', - 'queue' => ['default'], + 'queue' => [sprintf('%s-production-default', env('APP_TYPE'))], 'balance' => 'simple', 'processes' => 1, 'tries' => 3, ], 'supervisor-thumbnail' => [ 'connection' => 'redis', - 'queue' => ['thumbnail'], + 'queue' => [sprintf('%s-production-thumbnail', env('APP_TYPE'))], 'balance' => 'simple', 'processes' => 1, 'tries' => 1, @@ -159,14 +159,14 @@ 'local' => [ 'supervisor-default' => [ 'connection' => 'redis', - 'queue' => ['default'], + 'queue' => [sprintf('%s-local-default', env('APP_TYPE'))], 'balance' => 'simple', 'processes' => 1, 'tries' => 3, ], 'supervisor-thumbnail' => [ 'connection' => 'redis', - 'queue' => ['thumbnail'], + 'queue' => [sprintf('%s-local-thumbnail', env('APP_TYPE'))], 'balance' => 'simple', 'processes' => 1, 'tries' => 1, diff --git a/docs/lua.md b/docs/lua.md index 986d9209c..6ce1f09f8 100644 --- a/docs/lua.md +++ b/docs/lua.md @@ -2,7 +2,7 @@ So, hopefully I won't have to read this file ever again but here's some pointers about what needs to be done to install LUA on PHP. ## To install LUA and configure it -Run `storage/sh/setup_lua.sh`. +Run `./sh/setup_lua.sh`. ## Lua ``` diff --git a/docs/scheduler.md b/docs/scheduler.md new file mode 100644 index 000000000..bc3f7e1fb --- /dev/null +++ b/docs/scheduler.md @@ -0,0 +1,6 @@ +# Horizon +Horizon spawns workers which consume jobs. It does NOT generate jobs. + +# Scheduler +The Scheduler runs Scheduled Tasks at a specific time. These Tasks can do a bunch of things, but I use to it spawn Jobs. +The Scheduler is triggered from Crontab \ No newline at end of file diff --git a/resources/views/admin/tools/mdt/string.blade.php b/resources/views/admin/tools/mdt/string.blade.php index 65e792738..974a7d8bf 100644 --- a/resources/views/admin/tools/mdt/string.blade.php +++ b/resources/views/admin/tools/mdt/string.blade.php @@ -10,7 +10,7 @@ {{ Form::open(['route' => $dungeonroute ? 'admin.tools.mdt.string.viewasdungeonroute.submit' : 'admin.tools.mdt.string.submit']) }}
{!! Form::label('import_string', __('Paste your Method Dungeon Tools export string')) !!} - {{ Form::textarea('import_string', '', ['class' => 'form-control']) }} + {{ Form::textarea('import_string', '', ['class' => 'form-control', 'data-simplebar' => '']) }}
{!! Form::submit(__('Submit'), ['class' => 'btn btn-primary col-md-auto']) !!} diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index c0f26752b..14e312891 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -439,7 +439,7 @@
{!! Form::label('import_string', __('Paste your Method Dungeon Tools export string')) !!} - {{ Form::textarea('import_string_textarea', '', ['class' => 'form-control import_mdt_string_textarea']) }} + {{ Form::textarea('import_string_textarea', '', ['class' => 'form-control import_mdt_string_textarea', 'data-simplebar' => '']) }} {{ Form::hidden('import_string', '', ['class' => 'import_string']) }}
diff --git a/sh/setup_lua.sh b/sh/setup_lua.sh index ac0de1808..cd31b366e 100644 --- a/sh/setup_lua.sh +++ b/sh/setup_lua.sh @@ -3,8 +3,10 @@ # Install actual LUA language sudo apt-get remove liblua5.3 sudo apt-get remove lua5.3 -sudo apt-get install lua5.3 -sudo apt-get install liblua5.3 +sudo apt-get install -y lua5.3 \ + liblua5.3 \ + unzip \ + php-dev sudo ln -s /usr/include/lua5.3/ /usr/include/lua sudo cp /usr/lib/x86_64-linux-gnu/liblua5.3.a /usr/lib/liblua.a