Skip to content

Commit 1473654

Browse files
committed
feat(supervisor): add automated worker setup script
- Add interactive bash script to automate worker group creation - Support CLI arguments, environment variables, and .env files - Auto-resolve project external refs to internal IDs - Include dry-run mode for testing - Add --list-projects command to discover project IDs - Add comprehensive documentation in README with Quick Setup section - Include finding PAT instructions for all platforms - Add appendix explaining project ID types
1 parent 72594a4 commit 1473654

File tree

2 files changed

+649
-0
lines changed

2 files changed

+649
-0
lines changed

apps/supervisor/README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,114 @@
11
# Supervisor
22

3+
## Quick Setup (Recommended)
4+
5+
Use the automated setup script to create and configure workers.
6+
7+
### Prerequisites
8+
9+
- `curl` and `jq` installed
10+
- Personal Access Token (PAT) from your Trigger.dev instance
11+
12+
### Basic Usage
13+
14+
```bash
15+
# Interactive mode (will prompt for missing values)
16+
./scripts/setup-worker.sh
17+
18+
# With parameters
19+
./scripts/setup-worker.sh \
20+
--name my-worker \
21+
--pat tr_pat_... \
22+
--api-url https://trigger.example.com \
23+
--project-ref proj_... \
24+
--default
25+
```
26+
27+
### Examples
28+
29+
**Self-hosted with specific project:**
30+
31+
```bash
32+
./scripts/setup-worker.sh \
33+
--name production-worker \
34+
--pat tr_pat_... \
35+
--api-url https://trigger.example.com \
36+
--project-ref proj_... \
37+
--default
38+
```
39+
40+
**Using environment variables:**
41+
42+
```bash
43+
export TRIGGER_PAT=tr_pat_...
44+
export TRIGGER_API_URL=https://trigger.example.com
45+
export TRIGGER_WORKER_NAME=my-worker
46+
export TRIGGER_PROJECT_REF=proj_...
47+
48+
./scripts/setup-worker.sh --default
49+
```
50+
51+
**List available projects first:**
52+
53+
```bash
54+
./scripts/setup-worker.sh --list-projects
55+
```
56+
57+
**Dry-run (see what would happen):**
58+
59+
```bash
60+
./scripts/setup-worker.sh \
61+
--name test-worker \
62+
--project-ref proj_... \
63+
--dry-run
64+
```
65+
66+
### Script Options
67+
68+
| Option | Description |
69+
| --------------------- | ----------------------------------------- |
70+
| `--name <name>` | Worker group name (required) |
71+
| `--pat <token>` | Personal Access Token (tr*pat*...) |
72+
| `--api-url <url>` | Trigger.dev API URL |
73+
| `--project-ref <ref>` | Project external ref (proj\_...) |
74+
| `--project-id <id>` | Project internal ID (cmk...) |
75+
| `--default` | Make worker default for project |
76+
| `--list-projects` | List all projects and exit |
77+
| `--dry-run` | Show what would be done without executing |
78+
| `--help` | Show help message |
79+
80+
### Finding Your PAT
81+
82+
Your Personal Access Token is stored locally after running `trigger.dev login`:
83+
84+
**macOS:**
85+
86+
```bash
87+
cat ~/Library/Preferences/trigger/config.json | jq -r '.profiles.default.accessToken'
88+
# OR
89+
cat ~/Library/Application\ Support/trigger/config.json | jq -r '.profiles.default.accessToken'
90+
```
91+
92+
**Linux:**
93+
94+
```bash
95+
cat ~/.config/trigger/config.json | jq -r '.profiles.default.accessToken'
96+
```
97+
98+
**Windows:**
99+
100+
```powershell
101+
type %APPDATA%\trigger\config.json | jq -r ".profiles.default.accessToken"
102+
```
103+
104+
---
105+
3106
## Dev setup
4107

108+
**Quick Start:** Use the [automated setup script](#quick-setup-recommended) for easier configuration.
109+
110+
**Manual Setup:** Follow these steps if you prefer manual configuration:
111+
5112
1. Create a worker group
6113

7114
```sh
@@ -103,3 +210,32 @@ curl -sS \
103210

104211
- The project will then use the global default again
105212
- When `removeDefaultFromProject: true` no other actions will be performed
213+
214+
---
215+
216+
## Appendix: Project ID Types
217+
218+
Trigger.dev uses two types of project identifiers:
219+
220+
| Type | Format | Where Used | Example |
221+
| ---------------- | --------------- | ------------------------------- | --------------------------- |
222+
| **External Ref** | `proj_...` | trigger.config.ts, CLI commands | `proj_pxutendrlvklfzuatira` |
223+
| **Internal ID** | `cmk...` (CUID) | Admin APIs, Database operations | `cmkif24mo0005nu1yt2y5dkrf` |
224+
225+
The setup script automatically resolves external refs to internal IDs when needed.
226+
227+
### Getting Project Information
228+
229+
List all projects with both ID types:
230+
231+
```bash
232+
curl -sS \
233+
-H "Authorization: Bearer tr_pat_..." \
234+
"https://your-instance.trigger.dev/api/v1/projects" | jq
235+
```
236+
237+
Or use the setup script:
238+
239+
```bash
240+
./scripts/setup-worker.sh --list-projects --pat tr_pat_...
241+
```

0 commit comments

Comments
 (0)