IQRF PHP service manager

S6OverlayManager
in package
implements IServiceManager

Tool for managing services (s6-overlay v3 init system in a Docker container)

Only longrun services (supervised by s6) are supported. Enabling and disabling of services is not supported, services are started according to the compiled s6-rc database (user bundle).

Tags
see
https://github.com/just-containers/s6-overlay

Table of Contents

Interfaces

IServiceManager
Interface for tools for managing service

Constants

DEFAULT_SCAN_DIRECTORY  = '/run/service'
Default s6 scan directory used by s6-overlay v3

Properties

$commandManager  : CommandExecutor
$scanDirectory  : string

Methods

__construct()  : mixed
Constructor
disable()  : void
Disables service(s)
enable()  : void
Enables service(s)
exists()  : bool
Checks if the service exists (is supervised by s6)
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) including their dependencies
stop()  : void
Stops service(s) including services depending on them
changeState()  : void
Brings service(s) up or down via s6-rc
checkExists()  : void
Checks if the service exists
checkResult()  : void
Checks the result of the command
getServiceDirectory()  : string
Returns the escaped path to the service directory
isValidName()  : bool
Checks if the service name is valid (does not escape the scan directory)

Constants

DEFAULT_SCAN_DIRECTORY

Default s6 scan directory used by s6-overlay v3

public mixed DEFAULT_SCAN_DIRECTORY = '/run/service'

Properties

$scanDirectory read-only

private string $scanDirectory = self::DEFAULT_SCAN_DIRECTORY

Methods

__construct()

Constructor

public __construct(CommandExecutor $commandManager[, string $scanDirectory = self::DEFAULT_SCAN_DIRECTORY ]) : mixed
Parameters
$commandManager : CommandExecutor

Command manager

$scanDirectory : string = self::DEFAULT_SCAN_DIRECTORY

s6 scan directory containing service directories

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 (is supervised by s6)

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

The service does not exist

Return values
ServiceState —

Service state

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?

changeState()

Brings service(s) up or down via s6-rc

private changeState("-u"|"-d" $direction, string|array<string|int, string> $services) : void
Parameters
$direction : "-u"|"-d"

Direction (up or down)

$services : string|array<string|int, string>

Service name(s)

Tags
throws
NonexistentServiceException

The service does not exist

throws
ServiceOperationException

The operation failed

checkResult()

Checks the result of the command

private checkResult(ICommand $command) : void
Parameters
$command : ICommand

Executed command

Tags
throws
ServiceOperationException

The operation failed

getServiceDirectory()

Returns the escaped path to the service directory

private getServiceDirectory(string $serviceName) : string
Parameters
$serviceName : string

Service name

Return values
string —

Escaped path to the service directory

isValidName()

Checks if the service name is valid (does not escape the scan directory)

private isValidName(string $serviceName) : bool
Parameters
$serviceName : string

Service name

Return values
bool —

Is the service name valid?


        
On this page

Search results