Service
Service
Task wrapper responsible for launching and supervising service endpoints.
class Service extends \Hazaar\Warlock\Agent\TaskExtends: Hazaar\Warlock\Agent\Task
Properties
childConfig
public array $childConfigType: array
name
Service name to run on the server.
public string $name = 'Unnamed Service'Type: string
enabled
Whether this service task is currently enabled.
public bool $enabled = trueType: bool
info
public array $infoType: array
delay
Startup delay in seconds.
public int $delayType: int
loglevel
Log level applied to service output.
public LogLevel $loglevel = 'LogLevel'Type: Hazaar\Warlock\Enum\LogLevel
restarts
Number of times the service has been restarted since it last ran stably or came back from being disabled.
public int $restartsType: int
disabledUntil
Timestamp until which the service is disabled after too many restarts, or 0 when it isn't.
public int $disabledUntilType: int
heartbeatInterval
Seconds between the heartbeats the service sends.
public int $heartbeatInterval = 60Type: int
heartbeatMissed
Number of heartbeats in a row the service can miss before it's restarted. 0 disables the check.
public int $heartbeatMissed = 3Type: int
Methods
__construct
The $config array is forwarded verbatim to the running service as its own configuration,
public __construct(Main $agent, Logger $log, array $config): voidso it is kept as a raw array here; an Options instance is built from it internally to read the handful of fields this task wrapper itself cares about (delay, timezone).
Parameters
| Parameter | Type | Description |
|---|---|---|
$agent | Hazaar\Warlock\Agent\Main | |
$log | Hazaar\Warlock\Logger | |
$config | array |
run
Sends a service-start request to the server.
public run(): selfReturns: self
process
Supervises the service: whenever it stops, however it stopped, it is restarted.
public process(): selfReturns: self
Only cancelling the task (agent shutdown, task cancel) leaves a service stopped. Anything else that ends the process, a clean exit, an error exit, a signal or a failure to start, restarts it, up to service.restarts times, after which it is disabled for service.disable seconds and then started again.
missedHeartbeats
Checks whether a running service has gone heartbeatMissed intervals without a heartbeat.
public missedHeartbeats(?int $now): boolReturns: bool
The time since the service started counts as well, so a service that hangs before its first heartbeat is caught too, and a slow start gets the same grace as a missed heartbeat.
Parameters
| Parameter | Type | Description |
|---|---|---|
$now | int |
cancel
Cancels the service so it stays stopped.
public cancel(int $expire = 30): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$expire | int |
restart
Schedules the service to start again, or disables it for a while if it keeps stopping.
private restart(): voidReturns: void
processCommand
Handles service-task specific protocol commands.
protected processCommand(PacketType $command, mixed $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
Generated by Hazaar API Doc Generator on Thu, 22 Oct 2026 05:05:31 +0000