Laravel Forge JavaScript SDK

Workers

Workers

Create a worker

Method

forge.workers.create(server_id, site_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const worker = await forge.workers.create(server_id, site_id, payload);

Payload

1{
2 connection: 'sqs',
3 timeout: 90,
4 sleep: 60,
5 tries: null,
6 processes: 1,
7 daemon: true,
8 force: false,
9 php_version: 'php72'
10}

You may pass php as the php_version value to use the server's default PHP CLI version.

Example Response

1{
2 "worker": {
3 "id": 1,
4 "connection": "rule",
5 "command": "php7.2 /home/forge/default/artisan queue:work rule --sleep=60 --daemon --quiet --timeout=90",
6 "queue": null,
7 "timeout": 90,
8 "sleep": 60,
9 "tries": null,
10 "processes": 1,
11 "environment": null,
12 "php_version": "php72",
13 "daemon": 1,
14 "force": 0,
15 "status": "installing",
16 "created_at": "2016-12-17 07:15:03"
17 }
18}

List all workers for a site

Method

forge.workers.list(server_id, site_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const workers = await forge.workers.list(server_id, site_id);

Example Response

1{
2 "workers": [
3 {
4 "id": 1,
5 "connection": "rule",
6 "command": "php7.2 /home/forge/default/artisan queue:work rule --sleep=60 --daemon --quiet --timeout=90",
7 "queue": null,
8 "timeout": 90,
9 "sleep": 60,
10 "tries": null,
11 "processes": 1,
12 "environment": null,
13 "php_version": "php72",
14 "daemon": 1,
15 "force": 0,
16 "status": "installing",
17 "created_at": "2016-12-17 07:15:03"
18 }
19 ]
20}

Get a worker

Method

forge.workers.get(server_id, site_id, worker_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const worker = await forge.workers.get(server_id, site_id, worker_id);

Example Response

1{
2 "worker": {
3 "id": 1,
4 "connection": "rule",
5 "command": "php7.2 /home/forge/default/artisan queue:work rule --sleep=60 --daemon --quiet --timeout=90",
6 "queue": null,
7 "timeout": 90,
8 "sleep": 60,
9 "tries": null,
10 "processes": 1,
11 "environment": null,
12 "php_version": "php72",
13 "daemon": 1,
14 "force": 0,
15 "status": "installing",
16 "created_at": "2016-12-17 07:15:03"
17 }
18}

Delete a worker

Method

forge.workers.delete(server_id, site_id, worker_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.workers.delete(server_id, site_id, worker_id);

Restart a worker

Method

forge.workers.restart(server_id, site_id, worker_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.workers.restart(server_id, site_id, worker_id);

Edit this page on GitHub