IQRF PHP service manager

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

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
throws
NotImplementedException

The method is not implemented

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
throws
NotImplementedException

The method is not implemented

exists()

Checks if the service exists

public exists(string $serviceName) : bool
Parameters
$serviceName : string

Service name

Return values
bool —

Does the service exist?

getStatus()

Returns status of the service

public getStatus(string $serviceName) : string
Parameters
$serviceName : string

Service name

Tags
throws
NonexistentServiceException

The service does not exist

Return values
string —

Service status

isActive()

Checks if the service is active

public isActive(string $serviceName) : bool
Parameters
$serviceName : string

Service name

Tags
throws
NonexistentServiceException

The service does not exist

Return values
bool —

Is service active?

isEnabled()

Checks if the service is enabled

public isEnabled(string $serviceName) : bool
Parameters
$serviceName : string

Service name

Tags
throws
NotImplementedException

The method is not implemented

Return values
bool —

Is service enabled?

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
throws
NonexistentServiceException

The service does not exist

throws
ServiceOperationException

The operation failed

getProcessState()

Returns the process state (e.g. RUNNING, STOPPED, FATAL)

private getProcessState(string $serviceName) : string|null
Parameters
$serviceName : string

Service name

Tags
throws
NonexistentServiceException

The service does not exist

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


        
On this page

Search results