Skip to content

Commit 27fe5cd

Browse files
committed
update docs
1 parent 6c89332 commit 27fe5cd

1 file changed

Lines changed: 35 additions & 24 deletions

File tree

docs/services.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@ The UDX Worker uses `services.yaml` to define and manage multiple services. Each
1212

1313
## Configuration Structure
1414

15-
| Field | Type | Required | Default | Description |
16-
|-------|------|----------|---------|-------------|
17-
| `kind` | string | Yes | - | Must be `workerService` |
18-
| `version` | string | Yes | - | Must be `udx.io/worker-v1/service` |
19-
| `services` | array | Yes | - | List of service definitions |
15+
| Field | Type | Required | Default | Description |
16+
| ---------- | ------ | -------- | ------- | ---------------------------------- |
17+
| `kind` | string | Yes | - | Must be `workerService` |
18+
| `version` | string | Yes | - | Must be `udx.io/worker-v1/service` |
19+
| `services` | array | Yes | - | List of service definitions |
2020

2121
### Service Definition Fields
2222

23-
| Field | Type | Required | Default | Description |
24-
|-------|------|----------|---------|-------------|
25-
| `name` | string | Yes | - | Unique service identifier |
26-
| `command` | string | Yes | - | Command to execute |
27-
| `ignore` | boolean | No | `false` | Skip service management |
28-
| `autostart` | boolean | No | `true` | Start on worker launch |
29-
| `autorestart` | boolean | No | `false` | Restart on failure |
30-
| `envs` | array | No | `[]` | Environment variables |
23+
| Field | Type | Required | Default | Description |
24+
| ------------- | ------- | -------- | ------- | ------------------------- |
25+
| `name` | string | Yes | - | Unique service identifier |
26+
| `command` | string | Yes | - | Command to execute |
27+
| `ignore` | boolean | No | `false` | Skip service management |
28+
| `autostart` | boolean | No | `true` | Start on worker launch |
29+
| `autorestart` | boolean | No | `false` | Restart on failure |
30+
| `envs` | array | No | `[]` | Environment variables |
31+
| `stopasgroup` | boolean | No | `false` | Stop process group |
32+
| `killasgroup` | boolean | No | `false` | Kill process group |
3133

3234
## Basic Example
3335

@@ -56,6 +58,8 @@ services:
5658
command: "node api/server.js"
5759
autostart: true
5860
autorestart: true
61+
stopasgroup: true
62+
killasgroup: true
5963
envs:
6064
- "PORT=3000"
6165
- "NODE_ENV=production"
@@ -68,7 +72,7 @@ services:
6872

6973
- name: "monitoring"
7074
command: "./monitor.sh"
71-
ignore: true # Temporarily disabled
75+
ignore: true # Temporarily disabled
7276
```
7377
7478
### Service with Complex Command
@@ -87,16 +91,19 @@ services:
8791
## Best Practices
8892
8993
1. **Service Naming**
94+
9095
- Use descriptive, lowercase names
9196
- Separate words with hyphens
9297
- Keep names concise but meaningful
9398
9499
2. **Command Definition**
100+
95101
- Use absolute paths when possible
96102
- Quote commands with spaces or special characters
97103
- Consider using shell scripts for complex commands
98104
99105
3. **Environment Variables**
106+
100107
- Use uppercase for variable names
101108
- Group related variables together
102109
- Document required variables
@@ -110,39 +117,43 @@ services:
110117

111118
When running `worker service list`, services show the following status indicators:
112119

113-
| Symbol | Status | Description |
114-
|--------|---------|-------------|
115-
| ✅ | RUNNING | Service is running normally |
116-
| ⛔ | STOPPED | Service was stopped with `worker service stop` |
117-
| 💀 | FATAL | Service exited (any exit code) |
118-
| 🔄 | RETRY | Service is retrying (with autorestart: true) |
119-
| ⚠️ | STARTING | Service is starting up |
120+
| Symbol | Status | Description |
121+
| ------ | -------- | ---------------------------------------------- |
122+
| ✅ | RUNNING | Service is running normally |
123+
| ⛔ | STOPPED | Service was stopped with `worker service stop` |
124+
| 💀 | FATAL | Service exited (any exit code) |
125+
| 🔄 | RETRY | Service is retrying (with autorestart: true) |
126+
| ⚠️ | STARTING | Service is starting up |
120127

121128
### Service Types
122129

123130
1. **Long-running Services**
131+
124132
```yaml
125133
- name: "web-server"
126134
command: "python server.py"
127-
autorestart: true # Restarts on exit
135+
autorestart: true # Restarts on exit
128136
```
137+
129138
- Shows as RUNNING (✅) while active
130139
- Shows as RETRY (🔄) then FATAL (💀) if it keeps failing
131140

132141
2. **One-shot Tasks**
133142
```yaml
134143
- name: "setup"
135144
command: "./setup.sh"
136-
autorestart: false # Runs once
145+
autorestart: false # Runs once
137146
```
138147
- Use `worker service stop` for clean completion (⛔)
139148
- Otherwise shows as FATAL (💀) after exit
140149

141150
Note: Exit codes (0 or non-zero) don't affect the final status. What matters is:
151+
142152
- Whether the service keeps running (RUNNING ✅)
143153
- How it stops (STOPPED ⛔ vs FATAL 💀)
144154

145155
Example:
156+
146157
```bash
147158
# Long-running service and one-shot task
148159
$ worker service list
@@ -171,4 +182,4 @@ worker service logs web-server
171182
172183
# Restart a service
173184
worker service restart web-server
174-
```
185+
```

0 commit comments

Comments
 (0)