![]() |
Bearsampp 2026.9.23
|
Static Public Member Functions | |
| static | getAllServiceNames () |
| static | getBinFromServiceName ($serviceName, $bearsamppBins) |
| static | getServiceDisplayName ($bin, $service) |
| static | getServicePort ($serviceName, $bearsamppBins) |
| static | getSyntaxCheckCmd ($serviceName, $bearsamppBins=null) |
| static | hasSyntaxCheck ($serviceName) |
| static | installService ($bin, $port, $syntaxCheckCmd, $showWindow=false) |
| static | isPortInUse ($port) |
| static | processServices ($bearsamppBins, callable $callback) |
| static | removeService ($service, $name) |
| static | startAllServicesParallel ($serviceInfos, ?callable $progressCallback=null, $startupTimeout=30) |
| static | startService ($bin, $syntaxCheckCmd=null, $showWindow=false) |
| static | stopAllServicesParallel ($bearsamppBins, ?callable $progressCallback=null, $shutdownTimeout=15) |
| static | stopService ($service) |
Static Private Member Functions | |
| static | allServicesRunning ($serviceInfos) |
| static | allServicesStopped ($services) |
| static | forceKillService ($serviceName) |
| static | initializeMappings ($bearsamppBins) |
| static | shutdownServicesParallel ($services, ?callable $progressCallback=null, $shutdownTimeout=15) |
| static | shutdownServicesSequential ($services, ?callable $progressCallback=null) |
| static | startServicesParallel ($serviceInfos, ?callable $progressCallback=null, $startupTimeout=30) |
| static | startServicesSequential ($serviceInfos, ?callable $progressCallback=null) |
Static Private Attributes | |
| static | $serviceMap = null |
| static | $syntaxCheckMap = null |
Class ServiceHelper
Utility class for service management operations. Provides centralized methods for service lookup, syntax check commands, and common service operations to eliminate code duplication.
Definition at line 17 of file class.servicehelper.php.
|
staticprivate |
Check if all services are running
| array | $serviceInfos | Array of service information |
Definition at line 778 of file class.servicehelper.php.
Referenced by startServicesParallel(), and startServicesSequential().
|
staticprivate |
Check if all services are stopped
| array | $services | Array of services |
Definition at line 588 of file class.servicehelper.php.
Referenced by shutdownServicesParallel(), and shutdownServicesSequential().
|
staticprivate |
Force kill a service by process name
| string | $serviceName | The service name |
Definition at line 558 of file class.servicehelper.php.
References Win32Ps\killBins(), BinApache\SERVICE_NAME, BinMailpit\SERVICE_NAME, BinMariadb\SERVICE_NAME, BinMemcached\SERVICE_NAME, BinMysql\SERVICE_NAME, BinPostgresql\SERVICE_NAME, BinXlight\SERVICE_NAME, and Log\trace().
Referenced by shutdownServicesParallel(), and shutdownServicesSequential().
|
static |
Get all service names
Definition at line 340 of file class.servicehelper.php.
References BinApache\SERVICE_NAME, BinMailpit\SERVICE_NAME, BinMariadb\SERVICE_NAME, BinMemcached\SERVICE_NAME, BinMysql\SERVICE_NAME, BinPostgresql\SERVICE_NAME, and BinXlight\SERVICE_NAME.
|
static |
Get binary instance from service name
| string | $serviceName | The service name |
| object | $bearsamppBins | The bins object |
Definition at line 71 of file class.servicehelper.php.
References $bearsamppBins, and initializeMappings().
Referenced by getServicePort(), processServices(), and ActionRestartAllServices\processWindow().
|
static |
Get service display name (Name + Version + Service Name)
| object | $bin | The binary instance |
| object | $service | The service instance |
Definition at line 103 of file class.servicehelper.php.
Referenced by ActionRestartAllServices\processWindow(), and ActionStartAllServices\processWindow().
|
static |
Get port for a service
| string | $serviceName | The service name |
| object | $bearsamppBins | The bins object |
Definition at line 382 of file class.servicehelper.php.
References $bearsamppBins, and getBinFromServiceName().
|
static |
Get syntax check command for a service
| string | $serviceName | The service name |
| object | $bearsamppBins | The bins object (for initialization) |
Definition at line 86 of file class.servicehelper.php.
References $bearsamppBins, and initializeMappings().
Referenced by processServices(), and ActionRestartAllServices\processWindow().
|
static |
Check if a service has syntax check capability
| string | $serviceName | The service name |
Definition at line 360 of file class.servicehelper.php.
References BinApache\CMD_SYNTAX_CHECK, BinMariadb\CMD_SYNTAX_CHECK, BinMysql\CMD_SYNTAX_CHECK, BinApache\SERVICE_NAME, BinMariadb\SERVICE_NAME, and BinMysql\SERVICE_NAME.
|
staticprivate |
Initialize service mappings
| object | $bearsamppBins | The bins object |
Definition at line 40 of file class.servicehelper.php.
References $bearsamppBins, BinApache\CMD_SYNTAX_CHECK, BinMariadb\CMD_SYNTAX_CHECK, BinMysql\CMD_SYNTAX_CHECK, BinApache\SERVICE_NAME, BinMailpit\SERVICE_NAME, BinMariadb\SERVICE_NAME, BinMemcached\SERVICE_NAME, BinMysql\SERVICE_NAME, BinPostgresql\SERVICE_NAME, and BinXlight\SERVICE_NAME.
Referenced by getBinFromServiceName(), getSyntaxCheckCmd(), and processServices().
|
static |
Attempts to install and start a service on a specific port, with optional syntax checking and user notifications.
| object | $bin | An object containing the binary information and methods related to the service. |
| int | $port | The port number on which the service should run. |
| string | $syntaxCheckCmd | The command to execute for syntax checking of the service configuration. |
| bool | $showWindow | Optional. Whether to show message boxes for information, warnings, and errors. Defaults to false. |
Definition at line 227 of file class.servicehelper.php.
References $bearsamppLang, $port, Log\error(), Log\info(), Lang\INSTALL_SERVICE_TITLE, isPortInUse(), Lang\PORT_NOT_USED_BY, Lang\SERVICE_ALREADY_INSTALLED, Lang\SERVICE_INSTALL_ERROR, Lang\SERVICE_INSTALLED, Lang\STARTUP_SERVICE_SYNTAX_ERROR, and Log\warning().
Referenced by ActionService\install(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinPostgresql\setEnable(), and BinXlight\setEnable().
|
static |
Checks if a specific port is in use.
| int | $port | The port number to check |
Definition at line 191 of file class.servicehelper.php.
References $port, APP_LOCALHOST, and Batch\getProcessUsingPort().
Referenced by BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), BinPostgresql\handleNonPostgresUsage(), installService(), and ActionStartup\prepareService().
|
static |
Process all services with a callback function
| object | $bearsamppBins | The bins object |
| callable | $callback | Function to call for each service: function($serviceName, $service, $bin, $syntaxCheckCmd) |
Definition at line 116 of file class.servicehelper.php.
References $bearsamppBins, getBinFromServiceName(), getSyntaxCheckCmd(), and initializeMappings().
Referenced by ActionStartAllServices\processWindow().
|
static |
Removes a service if it is installed.
| Win32Service | $service | The service object to be removed. |
| string | $name | The name of the service. |
Definition at line 310 of file class.servicehelper.php.
References Log\error(), Log\info(), and Log\warning().
Referenced by ActionService\remove(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinPostgresql\setEnable(), and BinXlight\setEnable().
|
staticprivate |
Shutdown services in parallel (non-blocking)
Phase 1: Send stop commands to all services (non-blocking) Phase 2: Monitor their status until all stopped or timeout Phase 3: Force kill any services still running
| array | $services | Array of services |
| callable | null | $progressCallback | Optional progress callback |
| int | $shutdownTimeout | Timeout in seconds |
Definition at line 460 of file class.servicehelper.php.
References allServicesStopped(), forceKillService(), and Log\trace().
Referenced by stopAllServicesParallel().
|
staticprivate |
Shutdown services sequentially (fallback method)
Stops services one by one, waiting for each to complete. Used as fallback when parallel shutdown fails.
| array | $services | Array of services |
| callable | null | $progressCallback | Optional progress callback |
Definition at line 527 of file class.servicehelper.php.
References allServicesStopped(), forceKillService(), and Log\trace().
Referenced by stopAllServicesParallel().
|
static |
Start all services in parallel for optimized startup
Sends start commands to all services simultaneously, then monitors their status. Falls back to sequential startup if parallel fails. Significantly reduces startup time.
Performance: 40-60% faster startup (parallel vs sequential)
| array | $serviceInfos | Array of service information arrays with 'service', 'bin', 'name' keys |
| callable | null | $progressCallback | Optional callback: function($current, $total, $serviceName) |
| int | $startupTimeout | Timeout in seconds (default: 30) |
Definition at line 613 of file class.servicehelper.php.
References Log\info(), startServicesParallel(), startServicesSequential(), and Log\trace().
Referenced by ActionStartup\installServicesSequential().
|
static |
Start a service with optional syntax check
| object | $bin | The binary instance |
| string | null | $syntaxCheckCmd | The syntax check command (optional) |
| bool | $showWindow | Whether to show error messages in a window (default: false) |
Definition at line 139 of file class.servicehelper.php.
References $bearsamppLang, Log\error(), Lang\START_SERVICE_ERROR, Lang\START_SERVICE_TITLE, and Lang\STARTUP_SERVICE_SYNTAX_ERROR.
Referenced by ActionRestartAllServices\processWindow(), ActionStartAllServices\processWindow(), BinPhp\setEnable(), and ActionService\start().
|
staticprivate |
Start services in parallel (non-blocking)
Phase 1: Send start commands to all services (non-blocking) Phase 2: Monitor their status until all running or timeout Phase 3: Retry any services that failed to start
| array | $serviceInfos | Array of service information |
| callable | null | $progressCallback | Optional progress callback |
| int | $startupTimeout | Timeout in seconds |
Definition at line 659 of file class.servicehelper.php.
References allServicesRunning(), and Log\trace().
Referenced by startAllServicesParallel().
|
staticprivate |
Start services sequentially (fallback method)
Starts services one by one, waiting for each to complete. Used as fallback when parallel startup fails.
| array | $serviceInfos | Array of service information |
| callable | null | $progressCallback | Optional progress callback |
Definition at line 740 of file class.servicehelper.php.
References allServicesRunning(), and Log\trace().
Referenced by startAllServicesParallel().
|
static |
Stop all services in parallel for optimized shutdown
Sends stop commands to all services simultaneously, then monitors their status. Falls back to sequential shutdown if parallel fails. Significantly reduces shutdown time.
Performance: 40-60% faster shutdown (parallel vs sequential)
| object | $bearsamppBins | The bins object |
| callable | null | $progressCallback | Optional callback: function($current, $total, $serviceName) |
| int | $shutdownTimeout | Timeout in seconds (default: 15) |
Definition at line 413 of file class.servicehelper.php.
References $bearsamppBins, Log\info(), shutdownServicesParallel(), shutdownServicesSequential(), and Log\trace().
Referenced by ActionStopAllServices\processWindow().
|
static |
Stop a service
| object | $service | The service instance |
Definition at line 179 of file class.servicehelper.php.
Referenced by ActionRestartAllServices\processWindow().
|
staticprivate |
Definition at line 24 of file class.servicehelper.php.
|
staticprivate |
Definition at line 31 of file class.servicehelper.php.