laravelhorizon

How to change supervisor name on Horizon dashboard?


I've checked the source code and it seems that the name is determined from the server hostname and some random 4 characters string. What's the proper way to set it programmatically? Here's a sample: myserver-UME9


Solution

  • You can define a custom nameResolver on app/Providers/HorizonServiceProvider.php as shown below:

    <?php
    
    namespace App\Providers;
    
    ...
    use Laravel\Horizon\MasterSupervisor;
    ...
    
        /**
         * Bootstrap any application services.
         *
         * @return void
         */
        public function boot()
        {
            parent::boot();
    
            ...
    
            MasterSupervisor::determineNameUsing(function() {
              return "my_fancy_name";
              // return "my_fancy_name" . config('horizon.supervision_name');
            });
        }
    }