Service
Service
The Warlock application service class
Services are long running processes that allow code to be executed on the server in the background without affecting or requiring any interaction with the front-end. Services are managed by the Warlock process and can be set to start when Warlock starts or enabled/disabled manually using the Hazaar\Warlock\Control class.
Services are executed within the Application context and therefore have access to everything (configs, classes/models, cache, etc) that your application front-end does.
See the "Services Documentation":https://hazaar.dev/docs/components/warlock/services for information on how to write and manage services.
Properties
name
protected string $nameconfig
protected array $configschedule
protected array $schedulenext
public int $nextslept
protected bool $sleptlastCheckfile
private int $lastCheckfileserviceFile
private string $serviceFileserviceFileMtime
private int $serviceFileMtimeMethods
__construct
public __construct(Protocol $protocol, ?string $name, array $config): voidParameters
| Parameter | Type | Description |
|---|---|---|
$protocol | Protocol | |
$name | string | |
$config | array |
__processSchedule
private __processSchedule(): voidrun
Placeholder for the run method in case the service does not implement its own run method.
public run(): voiddelay
public delay(int $seconds, string $callback, array $arguments): stringParameters
| Parameter | Type | Description |
|---|---|---|
$seconds | int | |
$callback | string | |
$arguments | array |
interval
public interval(int $seconds, string $callback, array $params, ?string $tag, bool $overwrite): stringParameters
| Parameter | Type | Description |
|---|---|---|
$seconds | int | |
$callback | string | |
$params | array | |
$tag | string | |
$overwrite | bool |
schedule
public schedule(DateTime $date, string $callback, array $params, ?string $tag, bool $overwrite): stringParameters
| Parameter | Type | Description |
|---|---|---|
$date | DateTime | |
$callback | string | |
$params | array | |
$tag | string | |
$overwrite | bool |
cron
public cron(string $format, string $callback, ?array $arguments): stringParameters
| Parameter | Type | Description |
|---|---|---|
$format | string | |
$callback | string | |
$arguments | array |
sleep
protected sleep(int $timeout, Status $checkStatus = 'Status::RUNNING'): boolParameters
| Parameter | Type | Description |
|---|---|---|
$timeout | int | |
$checkStatus | Status |
initialize
Initializes the service by subscribing to events and scheduling actions
private initialize(array $config): boolbased on the provided configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | array |
Generated by Hazaar API Doc Generator on Sun, 01 Mar 2026 09:22:26 +0000