anbaric-cloud-hosting 1.24.0 → 1.25.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anbaric-cloud-hosting",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"description": "Anbaric Cloud hosting service: Postgres-backed job persistence and queuing exposed over an HTTP API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chris@anbaric.ai",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@aws-sdk/client-s3": "^3.1110.0",
|
|
19
19
|
"@aws-sdk/client-secrets-manager": "^3.700.0",
|
|
20
20
|
"@aws-sdk/client-servicediscovery": "^3.1110.0",
|
|
21
|
-
"anbaric-data-store": "^1.
|
|
22
|
-
"anbaric-plugins": "^1.
|
|
23
|
-
"anbaric-tsapi": "^1.
|
|
24
|
-
"anbaric-web": "^1.
|
|
21
|
+
"anbaric-data-store": "^1.25.0",
|
|
22
|
+
"anbaric-plugins": "^1.25.0",
|
|
23
|
+
"anbaric-tsapi": "^1.25.0",
|
|
24
|
+
"anbaric-web": "^1.25.0",
|
|
25
25
|
"esbuild": "^0.28.2",
|
|
26
26
|
"pg": "^8.16.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.2.0",
|
|
30
30
|
"@types/pg": "^8.15.0",
|
|
31
|
-
"anbaric-impl-cloud": "^1.
|
|
32
|
-
"anbaric-state-machine": "^1.
|
|
31
|
+
"anbaric-impl-cloud": "^1.25.0",
|
|
32
|
+
"anbaric-state-machine": "^1.25.0",
|
|
33
33
|
"tsx": "^4.20.0",
|
|
34
34
|
"typescript": "^7.0.2"
|
|
35
35
|
},
|
package/src/app-admin/launch.ts
CHANGED
|
@@ -9,6 +9,15 @@ import {AdminServer} from "./AdminServer";
|
|
|
9
9
|
and its admin port stops answering `ping`. */
|
|
10
10
|
const TSX = process.env.ANBARIC_TSX_BIN ?? "/anbaric/node_modules/.bin/tsx";
|
|
11
11
|
|
|
12
|
+
/* A host can name a module to load before the app's own entry point, which is
|
|
13
|
+
how it registers implementations an app picks up through the factories -
|
|
14
|
+
anything the app should be able to use without knowing it is there. It runs
|
|
15
|
+
in the app's process, so registering from the launcher would be too early. */
|
|
16
|
+
const preloadArgs = () => {
|
|
17
|
+
const preload = process.env.ANBARIC_APP_PRELOAD;
|
|
18
|
+
return preload ? ["--import", preload] : [];
|
|
19
|
+
};
|
|
20
|
+
|
|
12
21
|
const main = async () => {
|
|
13
22
|
const entryPoint = process.argv[2];
|
|
14
23
|
if (!entryPoint) throw new Error("Expected the app entry point as the first argument");
|
|
@@ -17,7 +26,7 @@ const main = async () => {
|
|
|
17
26
|
const port = await admin.listen();
|
|
18
27
|
console.log(`[anbaric-admin] listening on ${port}`);
|
|
19
28
|
|
|
20
|
-
const app = spawn(TSX, [entryPoint], { stdio: "inherit" });
|
|
29
|
+
const app = spawn(TSX, [...preloadArgs(), entryPoint], { stdio: "inherit" });
|
|
21
30
|
|
|
22
31
|
const shutdown = (signal : NodeJS.Signals) => app.kill(signal);
|
|
23
32
|
process.on("SIGTERM", shutdown);
|
|
@@ -49,9 +49,13 @@ class PostgresJobPersistence extends JobPersistence {
|
|
|
49
49
|
await client.query(
|
|
50
50
|
`INSERT INTO jobs (id, state, properties, workflow_id, app_id, started_at, started_by, last_updated, killed, status, waiting_for)
|
|
51
51
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
|
52
|
+
-- killed is deliberately not updated here. Only kill() sets it,
|
|
53
|
+
-- and a save carries whatever the job looked like when it was
|
|
54
|
+
-- read: a pass that began before a kill would otherwise write
|
|
55
|
+
-- killed=false straight back and bring the job back to life.
|
|
52
56
|
ON CONFLICT (id) DO UPDATE SET state = EXCLUDED.state, properties = EXCLUDED.properties,
|
|
53
57
|
workflow_id = EXCLUDED.workflow_id, app_id = EXCLUDED.app_id, last_updated = EXCLUDED.last_updated,
|
|
54
|
-
|
|
58
|
+
status = EXCLUDED.status, waiting_for = EXCLUDED.waiting_for`,
|
|
55
59
|
[job.id, job.state, Object.fromEntries(job.properties), job.workflowId, job.appId || null,
|
|
56
60
|
job.startedAt, job.startedBy, job.lastUpdated, job.killed, job.status, job.waitingFor ?? null],
|
|
57
61
|
);
|