SupervisordManager
in package
implements
IServiceManager
Tool for managing services (supervisord init daemon in a Docker container)
Enabling and disabling of services is not supported, services are started according to the autostart option in supervisord configuration.
Table of Contents
Interfaces
- IServiceManager
- Interface for tools for managing service
Constants
- NONEXISTENT_ERRORS = ['ERROR (no such process)', 'ERROR (no such group)']
- Error messages indicating nonexistent program
Properties
- $commandManager : CommandExecutor
Methods
- __construct() : mixed
- Constructor
- disable() : void
- Disables service(s)
- enable() : void
- Enables service(s)
- exists() : bool
- Checks if the service exists
- getState() : ServiceState
- Returns state of the service
- getStatus() : string
- Returns status of the service
- isActive() : bool
- Checks if the service is active
- isEnabled() : bool
- Checks if the service is enabled
- reload() : void
- Reloads the service configuration by sending SIGHUP to the service
- restart() : void
- Restarts the service, the service is started if it is not running
- start() : void
- Starts service(s)
- stop() : void
- Stops service(s)
- checkResult() : void
- Checks the result of supervisorctl action
- getProcessState() : string|null
- Returns the process state (e.g. RUNNING, STOPPED, FATAL)
- isNonexistent() : bool
- Checks if the command output indicates nonexistent program
- parseProcessState() : string|null
- Parses the process state from supervisorctl status output
- runCtl() : ICommand
- Runs supervisorctl action for the program
Constants
NONEXISTENT_ERRORS
Error messages indicating nonexistent program
private
mixed
NONEXISTENT_ERRORS
= ['ERROR (no such process)', 'ERROR (no such group)']
Properties
$commandManager read-only
private
CommandExecutor
$commandManager
Methods
__construct()
Constructor
public
__construct(CommandExecutor $commandManager) : mixed
Parameters
- $commandManager : CommandExecutor
-
Command manager
disable()
Disables service(s)
public
disable(string|array<string|int, string> $services[, bool $stop = true ]) : void
Parameters
- $services : string|array<string|int, string>
-
Service name(s)
- $stop : bool = true
-
Stop service(s) after disabling
Tags
enable()
Enables service(s)
public
enable(string|array<string|int, string> $services[, bool $start = true ]) : void
Parameters
- $services : string|array<string|int, string>
-
Service name(s)
- $start : bool = true
-
Start service(s) after enabling
Tags
exists()
Checks if the service exists
public
exists(string $serviceName) : bool
Parameters
- $serviceName : string
-
Service name
Return values
bool —Does the service exist?
getState()
Returns state of the service
public
getState(string $serviceName[, bool $withStatus = false ]) : ServiceState
Parameters
- $serviceName : string
-
Service name
- $withStatus : bool = false
-
Include service status?
Tags
Return values
ServiceState —Service state
getStatus()
Returns status of the service
public
getStatus(string $serviceName) : string
Parameters
- $serviceName : string
-
Service name
Tags
Return values
string —Service status
isActive()
Checks if the service is active
public
isActive(string $serviceName) : bool
Parameters
- $serviceName : string
-
Service name
Tags
Return values
bool —Is service active?
isEnabled()
Checks if the service is enabled
public
isEnabled(string $serviceName) : bool
Parameters
- $serviceName : string
-
Service name
Tags
Return values
bool —Is service enabled?
reload()
Reloads the service configuration by sending SIGHUP to the service
public
reload(string $serviceName) : void
Parameters
- $serviceName : string
-
Service name
Tags
restart()
Restarts the service, the service is started if it is not running
public
restart(string $serviceName) : void
Parameters
- $serviceName : string
-
Service name
Tags
start()
Starts service(s)
public
start(string|array<string|int, string> $services) : void
Parameters
- $services : string|array<string|int, string>
-
Service name(s)
Tags
stop()
Stops service(s)
public
stop(string|array<string|int, string> $services) : void
Parameters
- $services : string|array<string|int, string>
-
Service name(s)
Tags
checkResult()
Checks the result of supervisorctl action
private
checkResult(ICommand $command[, array<string|int, string> $ignoredErrors = [] ]) : void
Parameters
- $command : ICommand
-
Executed command
- $ignoredErrors : array<string|int, string> = []
-
Errors which do not indicate a failure (e.g. already started program)
Tags
getProcessState()
Returns the process state (e.g. RUNNING, STOPPED, FATAL)
private
getProcessState(string $serviceName) : string|null
Parameters
- $serviceName : string
-
Service name
Tags
Return values
string|null —Process state
isNonexistent()
Checks if the command output indicates nonexistent program
private
isNonexistent(ICommand $command) : bool
Parameters
- $command : ICommand
-
Executed command
Return values
bool —Does the program not exist?
parseProcessState()
Parses the process state from supervisorctl status output
private
parseProcessState(string $status) : string|null
Parameters
- $status : string
-
Output of supervisorctl status
Return values
string|null —Process state
runCtl()
Runs supervisorctl action for the program
private
runCtl(string $action, string $serviceName) : ICommand
Parameters
- $action : string
-
supervisorctl action
- $serviceName : string
-
Program name
Return values
ICommand —Executed command