VOOZH about

URL: https://deepwiki.com/hypervel/foundation/5.4-server-management-commands

⇱ Server Management Commands | hypervel/foundation | DeepWiki


Loading...
Last indexed: 7 February 2026 (101eff)
Menu

Server Management Commands

Purpose and Scope

Server Management Commands provide administrative utilities for managing and inspecting the Hypervel Foundation application. These commands are automatically registered via the ConfigProvider class and include tools for server lifecycle management, application introspection, configuration inspection, and asset publishing.

The framework provides four built-in management commands:

CommandClassPurpose
aboutAboutCommandDisplay application environment information
config:showConfigShowCommandDisplay configuration values
server:reloadServerReloadCommandGracefully reload worker processes
vendor:publishVendorPublishCommandPublish package assets and configuration

For information about general console command architecture and execution, see Console Kernel and Command Execution. For command discovery and registration mechanisms, see Command Discovery and Registration.

Sources: src/ConfigProvider.php31-36

Command Registration Architecture

All server management commands are registered through the ConfigProvider::__invoke() method, which returns a configuration array consumed by the Hyperf service container. The commands array specifies class names that are automatically instantiated and registered with the Artisan console application.

Diagram: Command Registration Flow


Sources: src/ConfigProvider.php31-36


AboutCommand

The AboutCommand class provides the about command, which displays comprehensive information about the application environment, installed packages, configuration, and system details.

PropertyValue
ClassHypervel\Foundation\Console\Commands\AboutCommand
Command Nameabout
RegistrationAutomatic via ConfigProvider

This command is useful for quickly inspecting the application environment during debugging or deployment verification.

Sources: src/ConfigProvider.php32


ConfigShowCommand

The ConfigShowCommand class provides the config:show command, which displays configuration values from the application's configuration system. This command allows developers to inspect resolved configuration without needing to access configuration files directly.

PropertyValue
ClassHypervel\Foundation\Console\Commands\ConfigShowCommand
Command Nameconfig:show
RegistrationAutomatic via ConfigProvider

This command is particularly useful for verifying that environment-specific configuration has been loaded correctly and for debugging configuration issues.

Sources: src/ConfigProvider.php33


VendorPublishCommand

The VendorPublishCommand class provides the vendor:publish command, which publishes assets and configuration files from installed packages to the application directory. This allows packages to provide default configuration that can be customized by the application.

PropertyValue
ClassHypervel\Foundation\Console\Commands\VendorPublishCommand
Command Namevendor:publish
RegistrationAutomatic via ConfigProvider

The command works in conjunction with the publish configuration key in package ConfigProviders, which defines source and destination paths for publishable assets. For example, the Foundation package itself publishes app.php configuration src/ConfigProvider.php37-44

Sources: src/ConfigProvider.php35 src/ConfigProvider.php37-44


ServerReloadCommand

The ServerReloadCommand class provides the server:reload command, which gracefully reloads all worker processes without stopping the server. This is essential for deploying code changes in production environments without service interruption by sending POSIX signals to the Swoole master process.

Command Specification

PropertyValue
ClassHypervel\Foundation\Console\Commands\ServerReloadCommand
Signatureserver:reload
DescriptionReload all workers gracefully.
Base ClassHypervel\Console\Command

The command operates by reading the master process PID from a configured file and sending POSIX signals to trigger worker reloads.

Sources: src/Console/Commands/ServerReloadCommand.php14-18


Dependencies

The ServerReloadCommand constructor injects three dependencies:

DependencyTypePurpose
$containerContainerInterfaceService container access
$configConfigInterfaceAccess to server.settings configuration
$filesystemFilesystemFile operations for reading PID file

Sources: src/Console/Commands/ServerReloadCommand.php20-26


Server Reload Flow

The following diagram illustrates the complete execution flow of the server:reload command:

Diagram: ServerReloadCommand Execution Flow


Sources: src/Console/Commands/ServerReloadCommand.php28-70


Configuration Requirements

The command requires the following configuration in config/server.php:

Configuration KeyTypeRequiredPurpose
server.settings.pid_filestringYesPath to file storing master process PID
server.settings.task_worker_numintNoNumber of task workers (0 = none)

If pid_file is not configured, a FileNotFoundException is thrown src/Console/Commands/ServerReloadCommand.php31-33

Sources: src/Console/Commands/ServerReloadCommand.php30-40


Signal Handling

The reload mechanism uses POSIX signals to communicate with the Swoole server master process:

Diagram: Signal-Based Worker Reload


Signal Reference

SignalConstantTargetAction
SIGUSR1User-defined signal 1Worker ProcessesTriggers graceful restart of all worker processes
SIGUSR2User-defined signal 2Task WorkersTriggers graceful restart of all task worker processes

The command uses posix_kill((int) $pid, 0) to verify the process is active before sending reload signals src/Console/Commands/ServerReloadCommand.php44-48

Sources: src/Console/Commands/ServerReloadCommand.php42-63


Graceful Reload Process

When SIGUSR1 or SIGUSR2 signals are received by the Swoole master process:

  1. Signal Reception: Master process receives the signal
  2. Worker Marking: Current workers are marked for shutdown after completing current requests
  3. New Worker Spawn: New workers are spawned with updated code
  4. Old Worker Shutdown: Once current requests complete, old workers shutdown
  5. Zero Downtime: New requests are handled by new workers while old workers finish gracefully

This ensures no requests are dropped and new code is loaded without server restart.

Sources: src/Console/Commands/ServerReloadCommand.php43-63


Error Handling

The command implements multiple error handling scenarios:

Diagram: Error Handling Paths





































Error ConditionLine RangeHandlerExit Code
PID file not configured30-33Throws FileNotFoundExceptionException
PID file doesn't exist35-38Warns and exits gracefully0
Process not active44-48, 57-61Warns but continues0
General failure64-67Catches Throwable, displays error1

Sources: src/Console/Commands/ServerReloadCommand.php28-70


Usage Examples

Basic Reload


Expected output:

Reloading workers...
Done.

Reload with Task Workers

When task_worker_num is configured:

Reloading workers...
Reloading task workers...
Done.

Error Scenarios

PID file not configured:

FileNotFoundException: The config of pid_file is not found.

Server not running:

pid_file doesn't exist.

Sources: src/Console/Commands/ServerReloadCommand.php14-70


Integration with Development Workflow

The server:reload command is typically used in development and deployment workflows:

Development Hot Reload

Combined with file watchers, developers can automatically reload workers when code changes:


Deployment Pipeline

In production deployments:


Related Components

The ReloadDotenvAndConfig listener works in conjunction with this command to hot-reload configuration changes when workers are restarted. The SetProcessTitle listener sets process titles that can be monitored during reloads. Both listeners are registered in the ConfigProvider.

Sources: src/ConfigProvider.php27-30


Technical Implementation Details

Process ID Management

The command relies on Swoole's built-in PID file management:

  1. Swoole master process writes its PID to server.settings.pid_file on startup
  2. The command reads this file to obtain the master process PID
  3. POSIX signals are sent directly to the master process
  4. The master process orchestrates worker reloads

Filesystem Operations

The Filesystem service provides two operations:

Task Worker Detection

Task workers are optional in Swoole. The command checks server.settings.task_worker_num to determine if task worker reload is needed src/Console/Commands/ServerReloadCommand.php40

Sources: src/Console/Commands/ServerReloadCommand.php20-26 src/Console/Commands/ServerReloadCommand.php30-63


Comparison with Other Server Management Approaches

ApproachDowntimeCode ReloadConfiguration ReloadCommand
Graceful ReloadNoneYesNoserver:reload
Server RestartYesYesYesserver:restart (if available)
Process ManagerDependsYesYesExternal (e.g., systemd)

The server:reload command is preferred for code deployments as it provides zero-downtime updates. For configuration changes requiring server restart, external process managers or manual restarts are necessary.

Sources: src/Console/Commands/ServerReloadCommand.php14-71