@andrian.yablonskyy/thub-coordinator 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/package.json +3 -3
- package/src/config.js +11 -8
- package/src/server.js +3 -1
package/README.md
CHANGED
|
@@ -7,14 +7,14 @@ See the [main TestHub repo](https://github.com/andrianyablonskyy/thub) for the f
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @andrian.yablonskyy/thub-coordinator
|
|
10
|
+
npm install -g @andrian.yablonskyy/thub-coordinator
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Or clone this repo directly and run it from source (see below).
|
|
13
|
+
This gives you two global commands: `thub-coordinator` (the server itself) and `thub-admin` (the local operator CLI, below). Or clone this repo directly and run it from source (see below).
|
|
14
14
|
|
|
15
15
|
## Configuration
|
|
16
16
|
|
|
17
|
-
The Coordinator loads a **JSON** config file (no YAML support
|
|
17
|
+
The Coordinator loads a plain **JSON** config file (no YAML support). Resolution order, first match wins: `THUB_COORDINATOR_CONFIG` env var path → `~/.config/thub/coordinator.json` → the bundled `config.json` default.
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
@@ -40,46 +40,46 @@ The Coordinator loads a **JSON** config file (no YAML support here, unlike the C
|
|
|
40
40
|
# password (creates user "admin") or use thub-admin afterwards.
|
|
41
41
|
THUB_COORDINATOR_CONFIG=/etc/thub/coordinator.json \
|
|
42
42
|
THUB_BOOTSTRAP_ADMIN_PASSWORD=correct-horse-battery-staple \
|
|
43
|
-
|
|
43
|
+
thub-coordinator
|
|
44
44
|
# -> Reset password for admin user "admin" from THUB_BOOTSTRAP_ADMIN_PASSWORD
|
|
45
45
|
# -> TestHub Coordinator listening on http://127.0.0.1:8080
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
`
|
|
48
|
+
`thub-coordinator` is the global command from `npm install -g`; from a local checkout of this repo it's `node src/server.js` or `npm start`/`npm run dev` (auto-restart on change) — all equivalent, all reading config the same way (above).
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
`THUB_BOOTSTRAP_ADMIN_PASSWORD` is more than a first-run convenience — it's an **exceptional password reset**, checked on every startup, not only when `admin_users` is empty. Whenever it's set, the named account (`THUB_BOOTSTRAP_ADMIN_USER`, default `admin`) has its password forced to it — creating that user as `admin` if it doesn't exist yet, or just resetting the password (never the role) if it does. With it unset, login uses whatever's already in the DB, as normal — unset it again once you're back in, or every subsequent restart re-applies it.
|
|
51
51
|
|
|
52
52
|
## `thub-admin` — the local operator CLI
|
|
53
53
|
|
|
54
|
-
Talks to the Coordinator's SQLite database directly — no running server required, and no HTTP auth of its own, so it's meant to be run on the Coordinator host itself
|
|
54
|
+
Talks to the Coordinator's SQLite database directly — no running server required, and no HTTP auth of its own, so it's meant to be run on the Coordinator host itself. `thub-admin` is the global command from `npm install -g`; from a local checkout it's `node bin/thub-admin.js`:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
57
|
# Create additional dashboard users (first one can also come from
|
|
58
58
|
# THUB_BOOTSTRAP_ADMIN_PASSWORD above).
|
|
59
|
-
|
|
59
|
+
thub-admin create-admin alice s3cret --role admin
|
|
60
60
|
|
|
61
61
|
# Register a CI or developer identity — the only credential still issued
|
|
62
62
|
# by an admin; the token is shown once.
|
|
63
|
-
|
|
63
|
+
thub-admin agent add ci-firmware --kind ci
|
|
64
64
|
# -> Agent agt_... created. Token (shown once): agt_...
|
|
65
65
|
|
|
66
66
|
# Mint the shared secret Clients use to self-register, and put it in both
|
|
67
67
|
# the Coordinator's clientJoinKey and every Client's joinKey.
|
|
68
|
-
|
|
68
|
+
thub-admin join-key generate
|
|
69
69
|
|
|
70
70
|
# Take a resource out of rotation without an active job (or bring it back).
|
|
71
|
-
|
|
71
|
+
thub-admin resource maintenance res_abc123 --on
|
|
72
72
|
|
|
73
73
|
# Cancel every queued/assigned/preparing/running job.
|
|
74
|
-
|
|
74
|
+
thub-admin jobs reset --yes
|
|
75
75
|
|
|
76
76
|
# Permanently delete every finished job, plus its logs and artifacts on disk.
|
|
77
|
-
|
|
77
|
+
thub-admin jobs clean --yes
|
|
78
78
|
|
|
79
79
|
# Resource groups: constrain which resources a job can schedule onto.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
thub-admin group add ci-nightly --comment "shared CI pool"
|
|
81
|
+
thub-admin group list
|
|
82
|
+
thub-admin group remove <groupId>
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
Both `jobs reset` and `jobs clean` refuse to run without `--yes` — there's no undo for either, especially `clean`.
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrian.yablonskyy/thub-coordinator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "TestHub Coordinator — job queue, resource registry, scheduler, heartbeat monitor, log/artifact store and web dashboard",
|
|
5
5
|
"main": "src/server.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"thub-admin": "./bin/thub-admin.js"
|
|
7
|
+
"thub-admin": "./bin/thub-admin.js",
|
|
8
|
+
"thub-coordinator": "./src/server.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"start": "node src/server.js",
|
|
@@ -18,7 +19,6 @@
|
|
|
18
19
|
"better-sqlite3": "^12.4.1",
|
|
19
20
|
"express": "^5.1.0",
|
|
20
21
|
"express-session": "^1.18.2",
|
|
21
|
-
"js-yaml": "^4.1.0",
|
|
22
22
|
"multer": "^2.0.2",
|
|
23
23
|
"pug": "^3.0.3",
|
|
24
24
|
"uuid": "^11.1.0"
|
package/src/config.js
CHANGED
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
16
|
const fs = require('node:fs'),
|
|
17
|
+
os = require('node:os'),
|
|
17
18
|
path = require('node:path');
|
|
18
19
|
|
|
19
|
-
// Defaults mirror README.md §13.
|
|
20
|
-
// is no FHS-path fallback here — a real deployment must set
|
|
21
|
-
// THUB_COORDINATOR_CONFIG explicitly to override the bundled default below.
|
|
20
|
+
// Defaults mirror README.md §13.
|
|
22
21
|
const DEFAULTS = {
|
|
23
22
|
listen: '127.0.0.1:8080',
|
|
24
23
|
publicUrl: 'http://localhost:8080',
|
|
@@ -63,13 +62,17 @@ function deepMerge(base, override){
|
|
|
63
62
|
return out;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
// User-level default (§13) — consulted when THUB_COORDINATOR_CONFIG isn't
|
|
66
|
+
// set, before falling back to the bundled default below.
|
|
67
|
+
const USER_CONFIG_PATH = path.join(os.homedir(), '.config', 'thub', 'coordinator.json'),
|
|
68
|
+
|
|
69
|
+
// Bundled with the package so the Coordinator has something sane to run
|
|
70
|
+
// with out of the box; a real deployment overrides it with
|
|
71
|
+
// THUB_COORDINATOR_CONFIG or ~/.config/thub/coordinator.json (§13).
|
|
72
|
+
PACKAGE_DEFAULT_CONFIG_PATH = path.join(__dirname, '..', 'config.json');
|
|
70
73
|
|
|
71
74
|
function loadConfig(configPath = process.env.THUB_COORDINATOR_CONFIG){
|
|
72
|
-
const candidate = [configPath, PACKAGE_DEFAULT_CONFIG_PATH].find(
|
|
75
|
+
const candidate = [configPath, USER_CONFIG_PATH, PACKAGE_DEFAULT_CONFIG_PATH].find(
|
|
73
76
|
(p) => p && fs.existsSync(p)
|
|
74
77
|
),
|
|
75
78
|
fileConfig = candidate ? JSON.parse(fs.readFileSync(candidate, 'utf8')) || {} : {},
|
package/src/server.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @file packages/coordinator/src/server.js
|
|
3
5
|
* @description Coordinator entry point: wires services, mounts routes, and starts the HTTP server
|
|
@@ -162,7 +164,7 @@ function ensureBootstrapAdmin(services){
|
|
|
162
164
|
if (services.adminUsers.count() === 0){
|
|
163
165
|
console.warn(
|
|
164
166
|
'No admin_users exist and THUB_BOOTSTRAP_ADMIN_PASSWORD is not set — ' +
|
|
165
|
-
'create one with:
|
|
167
|
+
'create one with: thub-admin create-admin <user> <password> (or node bin/thub-admin.js ... from a checkout)'
|
|
166
168
|
);
|
|
167
169
|
}
|
|
168
170
|
return;
|