Skip to content

A self-hosted media server and file management system

feat: install horizon

aminnausin2df356d22cdf
diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php
new file mode 100644
index 00000000..59599dc9
--- /dev/null
+++ b/app/Providers/HorizonServiceProvider.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\Facades\Gate;
+use Laravel\Horizon\Horizon;
+use Laravel\Horizon\HorizonApplicationServiceProvider;
+
+class HorizonServiceProvider extends HorizonApplicationServiceProvider
+{
+ /**
+ * Bootstrap any application services.
+ */
+ public function boot(): void
+ {
+ parent::boot();
+
+ // Horizon::routeSmsNotificationsTo('15556667777');
+ // Horizon::routeMailNotificationsTo('[email protected]');
+ // Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
+ }
+
+ /**
+ * Register the Horizon gate.
+ *
+ * This gate determines who can access Horizon in non-local environments.
+ */
+ protected function gate(): void
+ {
+ Gate::define('viewHorizon', function ($user = null) {
+ return in_array(optional($user)->email, [
+ //
+ ]);
+ });
+ }
+}
diff --git a/bootstrap/cache/packages.php b/bootstrap/cache/packages.php
index 26d95cb4..2f71ce2a 100755
--- a/bootstrap/cache/packages.php
+++ b/bootstrap/cache/packages.php
@@ -31,6 +31,17 @@
0 => 'HosmelQ\\Laravel\\Pulse\\Schedule\\ScheduleServiceProvider',
),
),
+ 'laravel/horizon' =>
+ array (
+ 'aliases' =>
+ array (
+ 'Horizon' => 'Laravel\\Horizon\\Horizon',
+ ),
+ 'providers' =>
+ array (
+ 0 => 'Laravel\\Horizon\\HorizonServiceProvider',
+ ),
+ ),
'laravel/pail' =>
array (
'providers' =>
diff --git a/bootstrap/cache/services.php b/bootstrap/cache/services.php
index 6f9c6c4a..42ada817 100755
--- a/bootstrap/cache/services.php
+++ b/bootstrap/cache/services.php
@@ -28,23 +28,25 @@
24 => 'Dedoc\\Scramble\\ScrambleServiceProvider',
25 => 'Denniseilander\\LogFiles\\LogFilesServiceProvider',
26 => 'HosmelQ\\Laravel\\Pulse\\Schedule\\ScheduleServiceProvider',
- 27 => 'Laravel\\Pail\\PailServiceProvider',
- 28 => 'Laravel\\Pulse\\PulseServiceProvider',
- 29 => 'Laravel\\Reverb\\ApplicationManagerServiceProvider',
- 30 => 'Laravel\\Reverb\\ReverbServiceProvider',
- 31 => 'Laravel\\Sail\\SailServiceProvider',
- 32 => 'Laravel\\Sanctum\\SanctumServiceProvider',
- 33 => 'Laravel\\Tinker\\TinkerServiceProvider',
- 34 => 'Livewire\\LivewireServiceProvider',
- 35 => 'Carbon\\Laravel\\ServiceProvider',
- 36 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
- 37 => 'Termwind\\Laravel\\TermwindServiceProvider',
- 38 => 'Opcodes\\LogViewer\\LogViewerServiceProvider',
- 39 => 'PauloHortelan\\RequestsGraphPulse\\RequestsGraphServiceProvider',
- 40 => 'Robertogallea\\PulseApi\\PulseAPIServiceProvider',
- 41 => 'App\\Providers\\AppServiceProvider',
+ 27 => 'Laravel\\Horizon\\HorizonServiceProvider',
+ 28 => 'Laravel\\Pail\\PailServiceProvider',
+ 29 => 'Laravel\\Pulse\\PulseServiceProvider',
+ 30 => 'Laravel\\Reverb\\ApplicationManagerServiceProvider',
+ 31 => 'Laravel\\Reverb\\ReverbServiceProvider',
+ 32 => 'Laravel\\Sail\\SailServiceProvider',
+ 33 => 'Laravel\\Sanctum\\SanctumServiceProvider',
+ 34 => 'Laravel\\Tinker\\TinkerServiceProvider',
+ 35 => 'Livewire\\LivewireServiceProvider',
+ 36 => 'Carbon\\Laravel\\ServiceProvider',
+ 37 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
+ 38 => 'Termwind\\Laravel\\TermwindServiceProvider',
+ 39 => 'Opcodes\\LogViewer\\LogViewerServiceProvider',
+ 40 => 'PauloHortelan\\RequestsGraphPulse\\RequestsGraphServiceProvider',
+ 41 => 'Robertogallea\\PulseApi\\PulseAPIServiceProvider',
42 => 'App\\Providers\\AppServiceProvider',
- 43 => 'App\\Providers\\PathResolverServiceProvider',
+ 43 => 'App\\Providers\\AppServiceProvider',
+ 44 => 'App\\Providers\\HorizonServiceProvider',
+ 45 => 'App\\Providers\\PathResolverServiceProvider',
),
'eager' =>
array (
@@ -61,20 +63,22 @@
10 => 'Barryvdh\\Debugbar\\ServiceProvider',
11 => 'Dedoc\\Scramble\\ScrambleServiceProvider',
12 => 'Denniseilander\\LogFiles\\LogFilesServiceProvider',
- 13 => 'Laravel\\Pail\\PailServiceProvider',
- 14 => 'Laravel\\Pulse\\PulseServiceProvider',
- 15 => 'Laravel\\Reverb\\ReverbServiceProvider',
- 16 => 'Laravel\\Sanctum\\SanctumServiceProvider',
- 17 => 'Livewire\\LivewireServiceProvider',
- 18 => 'Carbon\\Laravel\\ServiceProvider',
- 19 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
- 20 => 'Termwind\\Laravel\\TermwindServiceProvider',
- 21 => 'Opcodes\\LogViewer\\LogViewerServiceProvider',
- 22 => 'PauloHortelan\\RequestsGraphPulse\\RequestsGraphServiceProvider',
- 23 => 'Robertogallea\\PulseApi\\PulseAPIServiceProvider',
- 24 => 'App\\Providers\\AppServiceProvider',
+ 13 => 'Laravel\\Horizon\\HorizonServiceProvider',
+ 14 => 'Laravel\\Pail\\PailServiceProvider',
+ 15 => 'Laravel\\Pulse\\PulseServiceProvider',
+ 16 => 'Laravel\\Reverb\\ReverbServiceProvider',
+ 17 => 'Laravel\\Sanctum\\SanctumServiceProvider',
+ 18 => 'Livewire\\LivewireServiceProvider',
+ 19 => 'Carbon\\Laravel\\ServiceProvider',
+ 20 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
+ 21 => 'Termwind\\Laravel\\TermwindServiceProvider',
+ 22 => 'Opcodes\\LogViewer\\LogViewerServiceProvider',
+ 23 => 'PauloHortelan\\RequestsGraphPulse\\RequestsGraphServiceProvider',
+ 24 => 'Robertogallea\\PulseApi\\PulseAPIServiceProvider',
25 => 'App\\Providers\\AppServiceProvider',
- 26 => 'App\\Providers\\PathResolverServiceProvider',
+ 26 => 'App\\Providers\\AppServiceProvider',
+ 27 => 'App\\Providers\\HorizonServiceProvider',
+ 28 => 'App\\Providers\\PathResolverServiceProvider',
),
'deferred' =>
array (
diff --git a/bootstrap/providers.php b/bootstrap/providers.php
index 33f1d990..70c56a4e 100644
--- a/bootstrap/providers.php
+++ b/bootstrap/providers.php
@@ -2,5 +2,6 @@
return [
App\Providers\AppServiceProvider::class,
+ App\Providers\HorizonServiceProvider::class,
App\Providers\PathResolverServiceProvider::class,
];
diff --git a/composer.json b/composer.json
index ea12710b..216b831f 100755
--- a/composer.json
+++ b/composer.json
@@ -14,6 +14,7 @@
"denniseilander/pulse-log-files": "^0.2.0",
"hosmelq/laravel-pulse-schedule": "^0.2.2",
"laravel/framework": "^11.31",
+ "laravel/horizon": "^5.33",
"laravel/pulse": "^1.2",
"laravel/reverb": "^1.0",
"laravel/sanctum": "^4.0",
diff --git a/composer.lock b/composer.lock
index e9751e4d..3c57c838 100755
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "cc686f7ccc9b53841426ad4a672dab68",
+ "content-hash": "7fac91bab5e300ce3705501a912d987f",
"packages": [
{
"name": "brick/math",
@@ -1714,6 +1714,86 @@
},
"time": "2025-04-25T12:40:47+00:00"
},
+ {
+ "name": "laravel/horizon",
+ "version": "v5.33.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/laravel/horizon.git",
+ "reference": "50057bca1f1dcc9fbd5ff6d65143833babd784b3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/laravel/horizon/zipball/50057bca1f1dcc9fbd5ff6d65143833babd784b3",
+ "reference": "50057bca1f1dcc9fbd5ff6d65143833babd784b3",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "ext-pcntl": "*",
+ "ext-posix": "*",
+ "illuminate/contracts": "^9.21|^10.0|^11.0|^12.0",
+ "illuminate/queue": "^9.21|^10.0|^11.0|^12.0",
+ "illuminate/support": "^9.21|^10.0|^11.0|^12.0",
+ "nesbot/carbon": "^2.17|^3.0",
+ "php": "^8.0",
+ "ramsey/uuid": "^4.0",
+ "symfony/console": "^6.0|^7.0",
+ "symfony/error-handler": "^6.0|^7.0",
+ "symfony/polyfill-php83": "^1.28",
+ "symfony/process": "^6.0|^7.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "^1.0",
+ "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
+ "phpstan/phpstan": "^1.10",
+ "phpunit/phpunit": "^9.0|^10.4|^11.5",
+ "predis/predis": "^1.1|^2.0"
+ },
+ "suggest": {
+ "ext-redis": "Required to use the Redis PHP driver.",
+ "predis/predis": "Required when not using the Redis PHP driver (^1.1|^2.0)."
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "aliases": {
+ "Horizon": "Laravel\\Horizon\\Horizon"
+ },
+ "providers": [
+ "Laravel\\Horizon\\HorizonServiceProvider"
+ ]
+ },
+ "branch-alias": {
+ "dev-master": "6.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Laravel\\Horizon\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "[email protected]"
+ }
+ ],
+ "description": "Dashboard and code-driven configuration for Laravel queues.",
+ "keywords": [
+ "laravel",
+ "queue"
+ ],
+ "support": {
+ "issues": "https://github.com/laravel/horizon/issues",
+ "source": "https://github.com/laravel/horizon/tree/v5.33.1"
+ },
+ "time": "2025-06-16T13:48:30+00:00"
+ },
{
"name": "laravel/prompts",
"version": "v0.3.5",
diff --git a/config/horizon.php b/config/horizon.php
new file mode 100644
index 00000000..5101f6f0
--- /dev/null
+++ b/config/horizon.php
@@ -0,0 +1,213 @@
+<?php
+
+use Illuminate\Support\Str;
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Horizon Domain
+ |--------------------------------------------------------------------------
+ |
+ | This is the subdomain where Horizon will be accessible from. If this
+ | setting is null, Horizon will reside under the same domain as the
+ | application. Otherwise, this value will serve as the subdomain.
+ |
+ */
+
+ 'domain' => env('HORIZON_DOMAIN'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Horizon Path
+ |--------------------------------------------------------------------------
+ |
+ | This is the URI path where Horizon will be accessible from. Feel free
+ | to change this path to anything you like. Note that the URI will not
+ | affect the paths of its internal API that aren't exposed to users.
+ |
+ */
+
+ 'path' => env('HORIZON_PATH', 'horizon'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | 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',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Horizon Redis Prefix
+ |--------------------------------------------------------------------------
+ |
+ | This prefix will be used when storing all Horizon data in Redis. You
+ | may modify the prefix when you are running multiple installations
+ | of Horizon on the same server so that they don't have problems.
+ |
+ */
+
+ 'prefix' => env(
+ 'HORIZON_PREFIX',
+ Str::slug(env('APP_NAME', 'laravel'), '_').'_horizon:'
+ ),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Horizon Route Middleware
+ |--------------------------------------------------------------------------
+ |
+ | These middleware will get attached onto each Horizon route, giving you
+ | the chance to add your own middleware to this list or change any of
+ | the existing middleware. Or, you can simply stick with this list.
+ |
+ */
+
+ 'middleware' => ['web'],
+
+ /*
+ |--------------------------------------------------------------------------
+ | 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,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Job Trimming Times
+ |--------------------------------------------------------------------------
+ |
+ | Here you can configure for how long (in minutes) you desire Horizon to
+ | persist the recent and failed jobs. Typically, recent jobs are kept
+ | for one hour while all failed jobs are stored for an entire week.
+ |
+ */
+
+ 'trim' => [
+ 'recent' => 60,
+ 'pending' => 60,
+ 'completed' => 60,
+ 'recent_failed' => 10080,
+ 'failed' => 10080,
+ 'monitored' => 10080,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Silenced Jobs
+ |--------------------------------------------------------------------------
+ |
+ | Silencing a job will instruct Horizon to not place the job in the list
+ | of completed jobs within the Horizon dashboard. This setting may be
+ | used to fully remove any noisy jobs from the completed jobs list.
+ |
+ */
+
+ 'silenced' => [
+ // App\Jobs\ExampleJob::class,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Metrics
+ |--------------------------------------------------------------------------
+ |
+ | Here you can configure how many snapshots should be kept to display in
+ | the metrics graph. This will get used in combination with Horizon's
+ | `horizon:snapshot` schedule to define how long to retain metrics.
+ |
+ */
+
+ 'metrics' => [
+ 'trim_snapshots' => [
+ 'job' => 24,
+ 'queue' => 24,
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Fast Termination
+ |--------------------------------------------------------------------------
+ |
+ | When this option is enabled, Horizon's "terminate" command will not
+ | wait on all of the workers to terminate unless the --wait option
+ | is provided. Fast termination can shorten deployment delay by
+ | allowing a new instance of Horizon to start while the last
+ | instance will continue to terminate each of its workers.
+ |
+ */
+
+ 'fast_termination' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Memory Limit (MB)
+ |--------------------------------------------------------------------------
+ |
+ | This value describes the maximum amount of memory the Horizon master
+ | supervisor may consume before it is terminated and restarted. For
+ | configuring these limits on your workers, see the next section.
+ |
+ */
+
+ 'memory_limit' => 64,
+
+ /*
+ |--------------------------------------------------------------------------
+ | 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.
+ |
+ */
+
+ 'defaults' => [
+ 'supervisor-1' => [
+ 'connection' => 'redis',
+ 'queue' => ['default'],
+ 'balance' => 'auto',
+ 'autoScalingStrategy' => 'time',
+ 'maxProcesses' => 1,
+ 'maxTime' => 0,
+ 'maxJobs' => 0,
+ 'memory' => 128,
+ 'tries' => 1,
+ 'timeout' => 60,
+ 'nice' => 0,
+ ],
+ ],
+
+ 'environments' => [
+ 'production' => [
+ 'supervisor-1' => [
+ 'maxProcesses' => 10,
+ 'balanceMaxShift' => 1,
+ 'balanceCooldown' => 3,
+ ],
+ ],
+
+ 'local' => [
+ 'supervisor-1' => [
+ 'maxProcesses' => 3,
+ ],
+ ],
+ ],
+];