File manager - Edit - /var/www/payraty/helpdesk/public/storage/branding_media/images/Console.tar
Back
SupervisorStatusCommand.php 0000755 00000002725 00000000000 0012113 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\SupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:supervisor-status')] class SupervisorStatusCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:supervisor-status {name : The name of the supervisor}'; /** * The console command description. * * @var string */ protected $description = 'Show the status for a given supervisor'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\SupervisorRepository $supervisors * @return void */ public function handle(SupervisorRepository $supervisors) { $name = $this->argument('name'); $supervisorStatus = optional(collect($supervisors->all())->first(function ($supervisor) use ($name) { return Str::startsWith($supervisor->name, MasterSupervisor::basename()) && Str::endsWith($supervisor->name, $name); }))->status; if (is_null($supervisorStatus)) { $this->components->error('Unable to find a supervisor with this name.'); return 1; } $this->components->info("{$name} is {$supervisorStatus}"); } } PublishCommand.php 0000755 00000001355 00000000000 0010132 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:publish')] class PublishCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:publish'; /** * The console command description. * * @var string */ protected $description = 'Publish all of the Horizon resources'; /** * Execute the console command. * * @return void */ public function handle() { $this->components->warn('Horizon no longer publishes its assets. You may stop calling the `horizon:publish` command.'); } } TimeoutCommand.php 0000755 00000002333 00000000000 0010147 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\MasterSupervisor; use Laravel\Horizon\ProvisioningPlan; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:timeout')] class TimeoutCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:timeout {environment=production : The environment name}'; /** * The console command description. * * @var string */ protected $description = 'Get the maximum timeout for the given environment'; /** * Indicates whether the command should be shown in the Artisan command list. * * @var bool */ protected $hidden = true; /** * Execute the console command. * * @return void */ public function handle() { $plan = ProvisioningPlan::get(MasterSupervisor::name())->plan; $environment = $this->argument('environment'); $timeout = collect($plan[$this->argument('environment')] ?? [])->max('timeout') ?? 60; $this->components->info('Maximum timeout for '.$environment.' environment: '.$timeout.' seconds.'); } } TerminateCommand.php 0000755 00000004511 00000000000 0010451 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Contracts\Cache\Factory as CacheFactory; use Illuminate\Support\Arr; use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:terminate')] class TerminateCommand extends Command { use InteractsWithTime; /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:terminate {--wait : Wait for all workers to terminate}'; /** * The console command description. * * @var string */ protected $description = 'Terminate the master supervisor so it can be restarted'; /** * Execute the console command. * * @param \Illuminate\Contracts\Cache\Factory $cache * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masters * @return void */ public function handle(CacheFactory $cache, MasterSupervisorRepository $masters) { if (config('horizon.fast_termination')) { $cache->forever( 'horizon:terminate:wait', $this->option('wait') ); } $masters = collect($masters->all())->filter(function ($master) { return Str::startsWith($master->name, MasterSupervisor::basename()); })->all(); collect(Arr::pluck($masters, 'pid')) ->whenNotEmpty(fn () => $this->components->info('Sending TERM signal to processes.')) ->whenEmpty(fn () => $this->components->info('No processes to terminate.')) ->each(function ($processId) { $result = true; $this->components->task("Process: $processId", function () use ($processId, &$result) { return $result = posix_kill($processId, SIGTERM); }); if (! $result) { $this->components->error("Failed to kill process: {$processId} (".posix_strerror(posix_get_last_error()).')'); } })->whenNotEmpty(fn () => $this->output->writeln('')); $this->laravel['cache']->forever('illuminate:queue:restart', $this->currentTime()); } } ClearCommand.php 0000755 00000004034 00000000000 0007547 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; use Illuminate\Queue\QueueManager; use Illuminate\Support\Arr; use Laravel\Horizon\Contracts\JobRepository; use Laravel\Horizon\RedisQueue; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:clear')] class ClearCommand extends Command { use ConfirmableTrait; /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:clear {--queue= : The name of the queue to clear} {--force : Force the operation to run when in production}'; /** * The console command description. * * @var string */ protected $description = 'Delete all of the jobs from the specified queue'; /** * Execute the console command. * * @return int|null */ public function handle(JobRepository $jobRepository, QueueManager $manager) { if (! $this->confirmToProceed()) { return 1; } if (! method_exists(RedisQueue::class, 'clear')) { $this->components->error('Clearing queues is not supported on this version of Laravel.'); return 1; } $connection = Arr::first($this->laravel['config']->get('horizon.defaults'))['connection'] ?? 'redis'; if (method_exists($jobRepository, 'purge')) { $jobRepository->purge($queue = $this->getQueue($connection)); } $count = $manager->connection($connection)->clear($queue); $this->components->info('Cleared '.$count.' jobs from the ['.$queue.'] queue.'); return 0; } /** * Get the queue name to clear. * * @param string $connection * @return string */ protected function getQueue($connection) { return $this->option('queue') ?: $this->laravel['config']->get( "queue.connections.{$connection}.queue", 'default' ); } } PurgeCommand.php 0000755 00000010244 00000000000 0007603 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Laravel\Horizon\Contracts\ProcessRepository; use Laravel\Horizon\Contracts\SupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Laravel\Horizon\ProcessInspector; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:purge')] class PurgeCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:purge {--signal=SIGTERM : The signal to send to the rogue processes}'; /** * The console command description. * * @var string */ protected $description = 'Terminate any rogue Horizon processes'; /** * @var \Laravel\Horizon\Contracts\SupervisorRepository */ private $supervisors; /** * @var \Laravel\Horizon\Contracts\ProcessRepository */ private $processes; /** * @var \Laravel\Horizon\ProcessInspector */ private $inspector; /** * Create a new command instance. * * @param \Laravel\Horizon\Contracts\SupervisorRepository $supervisors * @param \Laravel\Horizon\Contracts\ProcessRepository $processes * @param \Laravel\Horizon\ProcessInspector $inspector * @return void */ public function __construct( SupervisorRepository $supervisors, ProcessRepository $processes, ProcessInspector $inspector ) { parent::__construct(); $this->supervisors = $supervisors; $this->processes = $processes; $this->inspector = $inspector; } /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masters * @return void */ public function handle(MasterSupervisorRepository $masters) { $signal = is_numeric($signal = $this->option('signal')) ? $signal : constant($signal); foreach ($masters->names() as $master) { if (Str::startsWith($master, MasterSupervisor::basename())) { $this->purge($master, $signal); } } } /** * Purge any orphan processes. * * @param string $master * @param int $signal * @return void */ public function purge($master, $signal = SIGTERM) { $this->recordOrphans($master, $signal); $expired = $this->processes->orphanedFor( $master, $this->supervisors->longestActiveTimeout() ); collect($expired) ->whenNotEmpty(fn () => $this->components->info('Sending TERM signal to expired processes of ['.$master.']')) ->each(function ($processId) use ($master, $signal) { $this->components->task("Process: $processId", function () use ($processId, $signal) { exec("kill -s {$signal} {$processId}"); }); $this->processes->forgetOrphans($master, [$processId]); })->whenNotEmpty(fn () => $this->output->writeln('')); } /** * Record the orphaned Horizon processes. * * @param string $master * @param int $signal * @return void */ protected function recordOrphans($master, $signal) { $this->processes->orphaned( $master, $orphans = $this->inspector->orphaned() ); collect($orphans) ->whenNotEmpty(fn () => $this->components->info('Sending TERM signal to orphaned processes of ['.$master.']')) ->each(function ($processId) use ($signal) { $result = true; $this->components->task("Process: $processId", function () use ($processId, $signal, &$result) { return $result = posix_kill($processId, $signal); }); if (! $result) { $this->components->error("Failed to kill orphan process: {$processId} (".posix_strerror(posix_get_last_error()).')'); } })->whenNotEmpty(fn () => $this->output->writeln('')); } } ForgetFailedCommand.php 0000755 00000004070 00000000000 0011054 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\JobRepository; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:forget')] class ForgetFailedCommand extends Command { /** * The console command signature. * * @var string */ protected $signature = 'horizon:forget {id? : The ID of the failed job} {--all : Delete all failed jobs}'; /** * The console command description. * * @var string */ protected $description = 'Delete a failed queue job'; /** * Execute the console command. * * @return int|null */ public function handle(JobRepository $repository) { if ($this->option('all')) { $totalFailedCount = $repository->totalFailed(); do { $failedJobs = collect($repository->getFailed()); $failedJobs->pluck('id')->each(function ($failedId) use ($repository): void { $repository->deleteFailed($failedId); if ($this->laravel['queue.failer']->forget($failedId)) { $this->components->info('Failed job (id): '.$failedId.' deleted successfully!'); } }); } while ($repository->totalFailed() !== 0 && $failedJobs->isNotEmpty()); if ($totalFailedCount) { $this->components->info($totalFailedCount.' failed jobs deleted successfully!'); } else { $this->components->info('No failed jobs detected.'); } return; } if (! $this->argument('id')) { $this->components->error('No failed job ID provided.'); } $repository->deleteFailed($this->argument('id')); if ($this->laravel['queue.failer']->forget($this->argument('id'))) { $this->components->info('Failed job deleted successfully!'); } else { $this->components->error('No failed job matches the given ID.'); return 1; } } } WorkCommand.php 0000755 00000004205 00000000000 0007443 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand; class WorkCommand extends BaseWorkCommand { /** * The console command name. * * @var string */ protected $signature = 'horizon:work {connection? : The name of the queue connection to work} {--name=default : The name of the worker} {--delay=0 : The number of seconds to delay failed jobs (Deprecated)} {--backoff=0 : The number of seconds to wait before retrying a job that encountered an uncaught exception} {--max-jobs=0 : The number of jobs to process before stopping} {--max-time=0 : The maximum number of seconds the worker should run} {--daemon : Run the worker in daemon mode (Deprecated)} {--force : Force the worker to run even in maintenance mode} {--memory=128 : The memory limit in megabytes} {--once : Only process the next job on the queue} {--stop-when-empty : Stop when the queue is empty} {--queue= : The names of the queues to work} {--sleep=3 : Number of seconds to sleep when no job is available} {--rest=0 : Number of seconds to rest between jobs} {--supervisor= : The name of the supervisor the worker belongs to} {--timeout=60 : The number of seconds a child process can run} {--tries=0 : Number of times to attempt a job before logging it failed}'; /** * Indicates whether the command should be shown in the Artisan command list. * * @var bool */ protected $hidden = true; /** * Execute the console command. * * @return void */ public function handle() { if (config('horizon.fast_termination')) { ignore_user_abort(true); } parent::handle(); } } ContinueCommand.php 0000755 00000003454 00000000000 0010312 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:continue')] class ContinueCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:continue'; /** * The console command description. * * @var string */ protected $description = 'Instruct the master supervisor to continue processing jobs'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masters * @return void */ public function handle(MasterSupervisorRepository $masters) { $masters = collect($masters->all())->filter(function ($master) { return Str::startsWith($master->name, MasterSupervisor::basename()); })->all(); collect(Arr::pluck($masters, 'pid')) ->whenNotEmpty(fn () => $this->components->info('Sending CONT signal to processes.')) ->whenEmpty(fn () => $this->components->info('No processes to continue.')) ->each(function ($processId) { $result = true; $this->components->task("Process: $processId", function () use ($processId, &$result) { return $result = posix_kill($processId, SIGCONT); }); if (! $result) { $this->components->error("Failed to kill process: {$processId} (".posix_strerror(posix_get_last_error()).')'); } })->whenNotEmpty(fn () => $this->output->writeln('')); } } SupervisorsCommand.php 0000755 00000003017 00000000000 0011065 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\SupervisorRepository; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:supervisors')] class SupervisorsCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:supervisors'; /** * The console command description. * * @var string */ protected $description = 'List all of the supervisors'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\SupervisorRepository $supervisors * @return void */ public function handle(SupervisorRepository $supervisors) { $supervisors = $supervisors->all(); if (empty($supervisors)) { return $this->components->info('No supervisors are running.'); } $this->output->writeln(''); $this->table([ 'Name', 'PID', 'Status', 'Workers', 'Balancing', ], collect($supervisors)->map(function ($supervisor) { return [ $supervisor->name, $supervisor->pid, $supervisor->status, collect($supervisor->processes)->map(function ($count, $queue) { return $queue.' ('.$count.')'; })->implode(', '), $supervisor->options['balance'], ]; })->all()); $this->output->writeln(''); } } SupervisorCommand.php 0000755 00000013132 00000000000 0010701 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Exception; use Illuminate\Console\Command; use Laravel\Horizon\SupervisorFactory; use Laravel\Horizon\SupervisorOptions; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:supervisor')] class SupervisorCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:supervisor {name : The name of supervisor} {connection : The name of the connection to work} {--balance= : The balancing strategy the supervisor should apply} {--delay=0 : The number of seconds to delay failed jobs (Deprecated)} {--backoff=0 : The number of seconds to wait before retrying a job that encountered an uncaught exception} {--max-jobs=0 : The number of jobs to process before stopping a child process} {--max-time=0 : The maximum number of seconds a child process should run} {--force : Force the worker to run even in maintenance mode} {--max-processes=1 : The maximum number of total workers to start} {--min-processes=1 : The minimum number of workers to assign per queue} {--memory=128 : The memory limit in megabytes} {--nice=0 : The process priority} {--paused : Start the supervisor in a paused state} {--queue= : The names of the queues to work} {--sleep=3 : Number of seconds to sleep when no job is available} {--timeout=60 : The number of seconds a child process can run} {--tries=0 : Number of times to attempt a job before logging it failed} {--auto-scaling-strategy=time : If supervisor should scale by jobs or time to complete} {--balance-cooldown=3 : The number of seconds to wait in between auto-scaling attempts} {--balance-max-shift=1 : The maximum number of processes to increase or decrease per one scaling} {--workers-name=default : The name that should be assigned to the workers} {--parent-id=0 : The parent process ID} {--rest=0 : Number of seconds to rest between jobs}'; /** * The console command description. * * @var string */ protected $description = 'Start a new supervisor'; /** * Indicates whether the command should be shown in the Artisan command list. * * @var bool */ protected $hidden = true; /** * Execute the console command. * * @param \Laravel\Horizon\SupervisorFactory $factory * @return int|null */ public function handle(SupervisorFactory $factory) { $supervisor = $factory->make( $this->supervisorOptions() ); try { $supervisor->ensureNoDuplicateSupervisors(); } catch (Exception $e) { $this->components->error('A supervisor with this name is already running.'); return 13; } $this->start($supervisor); } /** * Start the given supervisor. * * @param \Laravel\Horizon\Supervisor $supervisor * @return void */ protected function start($supervisor) { if ($supervisor->options->nice) { proc_nice($supervisor->options->nice); } $supervisor->handleOutputUsing(function ($type, $line) { $this->output->write($line); }); $supervisor->working = ! $this->option('paused'); $supervisor->scale(max( 0, $this->option('max-processes') - $supervisor->totalSystemProcessCount() )); $supervisor->monitor(); } /** * Get the supervisor options. * * @return \Laravel\Horizon\SupervisorOptions */ protected function supervisorOptions() { $backoff = $this->hasOption('backoff') ? $this->option('backoff') : $this->option('delay'); $balance = $this->option('balance'); $autoScalingStrategy = $balance === 'auto' ? $this->option('auto-scaling-strategy') : null; return new SupervisorOptions( $this->argument('name'), $this->argument('connection'), $this->getQueue($this->argument('connection')), $this->option('workers-name'), $balance, $backoff, $this->option('max-time'), $this->option('max-jobs'), $this->option('max-processes'), $this->option('min-processes'), $this->option('memory'), $this->option('timeout'), $this->option('sleep'), $this->option('tries'), $this->option('force'), $this->option('nice'), $this->option('balance-cooldown'), $this->option('balance-max-shift'), $this->option('parent-id'), $this->option('rest'), $autoScalingStrategy ); } /** * Get the queue name for the worker. * * @param string $connection * @return string */ protected function getQueue($connection) { return $this->option('queue') ?: $this->laravel['config']->get( "queue.connections.{$connection}.queue", 'default' ); } } PauseSupervisorCommand.php 0000755 00000003146 00000000000 0011703 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\SupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:pause-supervisor')] class PauseSupervisorCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:pause-supervisor {name : The name of the supervisor to pause}'; /** * The console command description. * * @var string */ protected $description = 'Pause a supervisor'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\SupervisorRepository $supervisors * @return void */ public function handle(SupervisorRepository $supervisors) { $processId = optional(collect($supervisors->all())->first(function ($supervisor) { return Str::startsWith($supervisor->name, MasterSupervisor::basename()) && Str::endsWith($supervisor->name, $this->argument('name')); }))->pid; if (is_null($processId)) { $this->components->error('Failed to find a supervisor with this name'); return 1; } $this->components->info("Sending USR2 signal to process: {$processId}"); if (! posix_kill($processId, SIGUSR2)) { $this->components->error("Failed to send USR2 signal to process: {$processId} (".posix_strerror(posix_get_last_error()).')'); } } } ContinueSupervisorCommand.php 0000755 00000003221 00000000000 0012404 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\SupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:continue-supervisor')] class ContinueSupervisorCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:continue-supervisor {name : The name of the supervisor to resume}'; /** * The console command description. * * @var string */ protected $description = 'Instruct the supervisor to continue processing jobs'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\SupervisorRepository $supervisors * @return void */ public function handle(SupervisorRepository $supervisors) { $processId = optional(collect($supervisors->all())->first(function ($supervisor) { return Str::startsWith($supervisor->name, MasterSupervisor::basename()) && Str::endsWith($supervisor->name, $this->argument('name')); }))->pid; if (is_null($processId)) { $this->components->error('Failed to find a supervisor with this name'); return 1; } $this->components->info("Sending CONT signal to process: {$processId}"); if (! posix_kill($processId, SIGCONT)) { $this->components->error("Failed to send CONT signal to process: {$processId} (".posix_strerror(posix_get_last_error()).')'); } } } InstallCommand.php 0000755 00000004753 00000000000 0010137 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:install')] class InstallCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:install'; /** * The console command description. * * @var string */ protected $description = 'Install all of the Horizon resources'; /** * Execute the console command. * * @return void */ public function handle() { $this->components->info('Installing Horizon resources.'); collect([ 'Service Provider' => fn () => $this->callSilent('vendor:publish', ['--tag' => 'horizon-provider']) == 0, 'Configuration' => fn () => $this->callSilent('vendor:publish', ['--tag' => 'horizon-config']) == 0, ])->each(fn ($task, $description) => $this->components->task($description, $task)); $this->registerHorizonServiceProvider(); $this->components->info('Horizon scaffolding installed successfully.'); } /** * Register the Horizon service provider in the application configuration file. * * @return void */ protected function registerHorizonServiceProvider() { $namespace = Str::replaceLast('\\', '', $this->laravel->getNamespace()); if (file_exists($this->laravel->bootstrapPath('providers.php'))) { ServiceProvider::addProviderToBootstrapFile("{$namespace}\\Providers\\HorizonServiceProvider"); } else { $appConfig = file_get_contents(config_path('app.php')); if (Str::contains($appConfig, $namespace.'\\Providers\\HorizonServiceProvider::class')) { return; } file_put_contents(config_path('app.php'), str_replace( "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL, "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." {$namespace}\Providers\HorizonServiceProvider::class,".PHP_EOL, $appConfig )); } file_put_contents(app_path('Providers/HorizonServiceProvider.php'), str_replace( "namespace App\Providers;", "namespace {$namespace}\Providers;", file_get_contents(app_path('Providers/HorizonServiceProvider.php')) )); } } StatusCommand.php 0000755 00000002373 00000000000 0010010 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:status')] class StatusCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:status'; /** * The console command description. * * @var string */ protected $description = 'Get the current status of Horizon'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masterSupervisorRepository * @return int */ public function handle(MasterSupervisorRepository $masterSupervisorRepository) { if (! $masters = $masterSupervisorRepository->all()) { $this->components->error('Horizon is inactive.'); return 2; } if (collect($masters)->contains(function ($master) { return $master->status === 'paused'; })) { $this->components->warn('Horizon is paused.'); return 1; } $this->components->info('Horizon is running.'); return 0; } } SnapshotCommand.php 0000755 00000002060 00000000000 0010315 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\MetricsRepository; use Laravel\Horizon\Lock; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:snapshot')] class SnapshotCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:snapshot'; /** * The console command description. * * @var string */ protected $description = 'Store a snapshot of the queue metrics'; /** * Execute the console command. * * @param \Laravel\Horizon\Lock $lock * @param \Laravel\Horizon\Contracts\MetricsRepository $metrics * @return void */ public function handle(Lock $lock, MetricsRepository $metrics) { if ($lock->get('metrics:snapshot', config('horizon.metrics.snapshot_lock', 300) - 30)) { $metrics->snapshot(); $this->components->info('Metrics snapshot stored successfully.'); } } } PauseCommand.php 0000755 00000003401 00000000000 0007573 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:pause')] class PauseCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:pause'; /** * The console command description. * * @var string */ protected $description = 'Pause the master supervisor'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masters * @return void */ public function handle(MasterSupervisorRepository $masters) { $masters = collect($masters->all())->filter(function ($master) { return Str::startsWith($master->name, MasterSupervisor::basename()); })->all(); collect(Arr::pluck($masters, 'pid')) ->whenNotEmpty(fn () => $this->components->info('Sending USR2 signal to processes.')) ->whenEmpty(fn () => $this->components->info('No processes to pause.')) ->each(function ($processId) { $result = true; $this->components->task("Process: $processId", function () use ($processId, &$result) { return $result = posix_kill($processId, SIGUSR2); }); if (! $result) { $this->components->error("Failed to kill process: {$processId} (".posix_strerror(posix_get_last_error()).')'); } })->whenNotEmpty(fn () => $this->output->writeln('')); } } ListCommand.php 0000755 00000002721 00000000000 0007435 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:list')] class ListCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:list'; /** * The console command description. * * @var string */ protected $description = 'List all of the deployed machines'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masters * @return void */ public function handle(MasterSupervisorRepository $masters) { $masters = $masters->all(); if (empty($masters)) { return $this->components->info('No machines are running.'); } $this->output->writeln(''); $this->table([ 'Name', 'PID', 'Supervisors', 'Status', ], collect($masters)->map(function ($master) { return [ $master->name, $master->pid, $master->supervisors ? collect($master->supervisors)->map(function ($supervisor) { return explode(':', $supervisor, 2)[1]; })->implode(', ') : 'None', $master->status, ]; })->all()); $this->output->writeln(''); } } HorizonCommand.php 0000755 00000003317 00000000000 0010154 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\MasterSupervisorRepository; use Laravel\Horizon\MasterSupervisor; use Laravel\Horizon\ProvisioningPlan; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon')] class HorizonCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon {--environment= : The environment name}'; /** * The console command description. * * @var string */ protected $description = 'Start a master supervisor in the foreground'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masters * @return void */ public function handle(MasterSupervisorRepository $masters) { if ($masters->find(MasterSupervisor::name())) { return $this->components->warn('A master supervisor is already running on this machine.'); } $environment = $this->option('environment') ?? config('horizon.env') ?? config('app.env'); $master = (new MasterSupervisor($environment))->handleOutputUsing(function ($type, $line) { $this->output->write($line); }); ProvisioningPlan::get(MasterSupervisor::name())->deploy($environment); $this->components->info('Horizon started successfully.'); pcntl_async_signals(true); pcntl_signal(SIGINT, function () use ($master) { $this->output->writeln(''); $this->components->info('Shutting down.'); return $master->terminate(); }); $master->monitor(); } } ClearMetricsCommand.php 0000755 00000001557 00000000000 0011105 0 ustar 00 <?php namespace Laravel\Horizon\Console; use Illuminate\Console\Command; use Laravel\Horizon\Contracts\MetricsRepository; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:clear-metrics')] class ClearMetricsCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'horizon:clear-metrics'; /** * The console command description. * * @var string */ protected $description = 'Delete metrics for all jobs and queues'; /** * Execute the console command. * * @param \Laravel\Horizon\Contracts\MetricsRepository $metrics * @return void */ public function handle(MetricsRepository $metrics) { $metrics->clear(); $this->components->info('Metrics cleared successfully.'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings