@alexberardi/jarvis-admin 0.1.39 → 0.1.40
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,15 +1,14 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
2
|
type Emit = (data: Record<string, unknown>) => void;
|
|
3
3
|
/**
|
|
4
|
-
* Run the full upgrade flow
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 7. Verify health
|
|
4
|
+
* Run the full upgrade flow.
|
|
5
|
+
*
|
|
6
|
+
* Two modes:
|
|
7
|
+
* - **Standalone binary**: download new binary, swap, restart, then resume
|
|
8
|
+
* with compose regeneration + service updates.
|
|
9
|
+
* - **Docker container**: skip binary self-update (admin container is updated
|
|
10
|
+
* separately via `docker compose pull`). Go straight to compose regeneration,
|
|
11
|
+
* image pull, and service restart.
|
|
13
12
|
*/
|
|
14
13
|
export declare function runUpgrade(targetVersion: string, app: FastifyInstance, emit: Emit): Promise<void>;
|
|
15
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/upgrade/orchestrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/upgrade/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;AAMnD;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,IAAI,CAAC,CAiBf;AA+BD;;GAEG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC7D,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import { selfUpdate } from './self-updater.js';
|
|
2
3
|
import { upgradeCompose } from './compose-upgrader.js';
|
|
4
|
+
function isRunningInDocker() {
|
|
5
|
+
return existsSync('/.dockerenv');
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
|
-
* Run the full upgrade flow
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 7. Verify health
|
|
8
|
+
* Run the full upgrade flow.
|
|
9
|
+
*
|
|
10
|
+
* Two modes:
|
|
11
|
+
* - **Standalone binary**: download new binary, swap, restart, then resume
|
|
12
|
+
* with compose regeneration + service updates.
|
|
13
|
+
* - **Docker container**: skip binary self-update (admin container is updated
|
|
14
|
+
* separately via `docker compose pull`). Go straight to compose regeneration,
|
|
15
|
+
* image pull, and service restart.
|
|
13
16
|
*/
|
|
14
17
|
export async function runUpgrade(targetVersion, app, emit) {
|
|
15
18
|
// Phase 1: Preflight
|
|
@@ -17,11 +20,37 @@ export async function runUpgrade(targetVersion, app, emit) {
|
|
|
17
20
|
if (!app.docker) {
|
|
18
21
|
throw new Error('Docker is not available');
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
if (isRunningInDocker()) {
|
|
24
|
+
// Docker mode: skip binary self-update, run the service upgrade inline
|
|
25
|
+
await runDockerUpgrade(targetVersion, app, emit);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Standalone mode: download binary, swap, restart (resumes via marker)
|
|
29
|
+
emit({ phase: 'download', message: `Downloading Jarvis v${targetVersion}...` });
|
|
30
|
+
await selfUpdate(targetVersion, emit);
|
|
31
|
+
// Phase 3 happens inside selfUpdate: atomic swap + restart marker + process restart
|
|
32
|
+
// After restart, the new binary reads the marker and calls resumeUpgrade()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Docker-mode upgrade: regenerate compose, pull images, restart services.
|
|
37
|
+
* Admin container itself is NOT updated here — user pulls it separately.
|
|
38
|
+
*/
|
|
39
|
+
async function runDockerUpgrade(targetVersion, app, emit) {
|
|
40
|
+
// Regenerate compose + merge env
|
|
41
|
+
emit({ phase: 'compose', message: 'Updating configuration...' });
|
|
42
|
+
await upgradeCompose(app);
|
|
43
|
+
// Pull new images
|
|
44
|
+
emit({ phase: 'pull', message: 'Pulling updated images...' });
|
|
45
|
+
const { pullImages, restartServices, verifyHealth } = await import('./service-updater.js');
|
|
46
|
+
await pullImages(app, emit);
|
|
47
|
+
// Restart services
|
|
48
|
+
emit({ phase: 'restart', message: 'Restarting services...' });
|
|
49
|
+
await restartServices(app, emit);
|
|
50
|
+
// Verify health
|
|
51
|
+
emit({ phase: 'verify', message: 'Verifying health...' });
|
|
52
|
+
await verifyHealth(app, emit);
|
|
53
|
+
emit({ phase: 'done', message: `Upgrade to v${targetVersion} complete! To update admin itself: docker compose pull jarvis-admin && docker compose up -d --force-recreate jarvis-admin` });
|
|
25
54
|
}
|
|
26
55
|
/**
|
|
27
56
|
* Resume upgrade after binary restart. Called from startup hook.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/services/upgrade/orchestrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/services/upgrade/orchestrator.ts"],"names":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