class SystemDaemon extends SystemDaemonThreaded

Constants

private THREAD_CONFIG_CHECK_INTERVAL

Properties

array $cmd_params from  SystemDaemon
$daemon_name
$module_name
mixed $view from  SystemDaemon
$sleep_between_process
int $process_counter from  SystemDaemon
mixed $mod_registry from  SystemDaemon
bool $shutdown from  SystemDaemon
string $sleeping from  SystemDaemon
array $messages from  SystemDaemon
protected float|int $requestCacheClearingTime from  SystemDaemon
protected int $lastRequestCacheClearingTime from  SystemDaemon
protected $maxThreadCount
protected $threadLifetimeCycles from  SystemDaemonThreaded
protected JobQueueController $mod
protected string[] $queues
protected int $maintenanceLastCheck
protected int $maintenanceKeepHistoryDays

Methods

__construct()

Initialize Instances

__destruct()

No description

void
_threadShutdown()

Handle Logging of Fatal Errors and add Log-Entry to Job

void
afterThreadFinished(string $threadIdentifier, int $threadProcessId, int $exitStatus)

Gets called if a thread finishes It can be used e.g. to clean up unfinished work in case of an ABORTED exit status

void
beforeNewThreadStart(string $threadIdentifier, array $threadOptions)

Gets calles before a Thread is being started Use this place to e.g. initialize/update static caches which can be reused in each thread to avoid init within each thread

void
beforeProcess()

Check for Maintenance Tasks

beginThread()

Called after a new Thread has been started. Is only called once per thread.

endThread()

Gets called within a thread before stopping thread

int
getRequiredThreadCount()

Calculate the number of threads we should currently use. If we have no open jobs we reduce the number of running threads to reduce system load. We scale threads dynamic to match workload.

array
getThreadConfig()

Returns an array with all threads which should run and their options By default we use the configured number of Max Threads

halt()

No description

bool
handleProcessThread(string $threadIdentifier, array $threadOptions)

Default Entry Point for each Thread which covers the basic abort checks and thread lifetime handling

bool
isShutdown()

Returns true if the daemon process is in the shutdown phase to be ended

void
load_module_instances(mixed $module)

No description

message(string $message, string $level = Logger::INFO)

Daemon message

onStartup()

Startup of Daemon (Fail all aborted jobs on this node)

void
onThreadError(string $threadIdentifier, int $threadProcessId, int $exitStatus)

Mark jobs as failed if a thread fails

process()

Main Daemon Process used to orchestrate all working threads Important: Must not contain any blocking operations

bool
processThread(string $threadIdentifier, array $threadOptions)

Main Process Loop for each Thread to fetch and process each job. Called multiple times per thread.

registerSignalHandler()

No description

static 
restart_all()

Restart all Daemons

signalHandler(int $signo, mixed $siginfo)

No description

start()

No description

static 
start_all(bool $if_running_on_this_node = false)

Start all Daemons

static 
stop_all(bool $if_running_on_this_node = false)

Stop all Daemons

Details

at line 41
__construct()

Initialize Instances

Exceptions

Exception

in SystemDaemon at line 363
__destruct()

No description

at line 112
void _threadShutdown()

Handle Logging of Fatal Errors and add Log-Entry to Job

Return Value

void

in SystemDaemonThreaded at line 225
void afterThreadFinished(string $threadIdentifier, int $threadProcessId, int $exitStatus)

Gets called if a thread finishes It can be used e.g. to clean up unfinished work in case of an ABORTED exit status

Parameters

string $threadIdentifier
int $threadProcessId
int $exitStatus

Return Value

void

in SystemDaemonThreaded at line 213
void beforeNewThreadStart(string $threadIdentifier, array $threadOptions)

Gets calles before a Thread is being started Use this place to e.g. initialize/update static caches which can be reused in each thread to avoid init within each thread

Parameters

string $threadIdentifier
array $threadOptions

Return Value

void

at line 150
void beforeProcess()

Check for Maintenance Tasks

Return Value

void

at line 71
beginThread()

Called after a new Thread has been started. Is only called once per thread.

endThread()

Gets called within a thread before stopping thread

at line 128
int getRequiredThreadCount()

Calculate the number of threads we should currently use. If we have no open jobs we reduce the number of running threads to reduce system load. We scale threads dynamic to match workload.

Return Value

int

Number of Threads

in SystemDaemonThreaded at line 183
array getThreadConfig()

Returns an array with all threads which should run and their options By default we use the configured number of Max Threads

Return Value

array

Thread Configuration - keyed array with the threadIdentifier as key and an assoc array with the threadOptions

in SystemDaemon at line 336
halt()

No description

final bool handleProcessThread(string $threadIdentifier, array $threadOptions)

Default Entry Point for each Thread which covers the basic abort checks and thread lifetime handling

Parameters

string $threadIdentifier
array $threadOptions

Return Value

bool

in SystemDaemon at line 224
bool isShutdown()

Returns true if the daemon process is in the shutdown phase to be ended

Return Value

bool

in SystemDaemon at line 165
void load_module_instances(mixed $module)

No description

Parameters

mixed $module

Return Value

void

Exceptions

Exception

in SystemDaemon at line 313
message(string $message, string $level = Logger::INFO)

Daemon message

Parameters

string $message Message
string $level Logger::XXXX

at line 59
onStartup()

Startup of Daemon (Fail all aborted jobs on this node)

Exceptions

JsonException

at line 142
void onThreadError(string $threadIdentifier, int $threadProcessId, int $exitStatus)

Mark jobs as failed if a thread fails

Parameters

string $threadIdentifier
int $threadProcessId
int $exitStatus

Return Value

void

Exceptions

JsonException

final process()

Main Daemon Process used to orchestrate all working threads Important: Must not contain any blocking operations

at line 84
bool processThread(string $threadIdentifier, array $threadOptions)

Main Process Loop for each Thread to fetch and process each job. Called multiple times per thread.

Being called by parent class logic to start a new thread

Parameters

string $threadIdentifier
array $threadOptions

Return Value

bool

Return true

in SystemDaemon at line 371
protected registerSignalHandler()

No description

in SystemDaemon at line 110
static restart_all()

Restart all Daemons

in SystemDaemon at line 386
signalHandler(int $signo, mixed $siginfo)

No description

Parameters

int $signo
mixed $siginfo

in SystemDaemon at line 183
start()

No description

in SystemDaemon at line 125
static start_all(bool $if_running_on_this_node = false)

Start all Daemons

Parameters

bool $if_running_on_this_node

True will only start daemons which are known to have run on this node before they were stopped

in SystemDaemon at line 145
static stop_all(bool $if_running_on_this_node = false)

Stop all Daemons

Parameters

bool $if_running_on_this_node

True will only stop daemons which are known to run on this node