neurastream 0.2.8 → 0.2.9
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 +1 -1
- package/src/cli/ui.ts +22 -11
package/package.json
CHANGED
package/src/cli/ui.ts
CHANGED
|
@@ -3,18 +3,27 @@
|
|
|
3
3
|
// two refusals. Runs until killed (systemd user unit templates/systemd/neurastream-ui.service).
|
|
4
4
|
|
|
5
5
|
import { defaultRunSource } from "../adapters/omp/sessions.ts";
|
|
6
|
-
import { ConfigError, loadConfig } from "../core/config.ts";
|
|
7
|
-
import { startOwnerUi } from "../core/owner-ui.ts";
|
|
6
|
+
import { ConfigError, loadConfig, type Config } from "../core/config.ts";
|
|
7
|
+
import { startOwnerUi, type OwnerUiOptions, type OwnerUiServer } from "../core/owner-ui.ts";
|
|
8
8
|
import { applyQueueEnv } from "../core/queue/env.ts";
|
|
9
9
|
import { realTailscale } from "../core/tailscale.ts";
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export interface UiDeps {
|
|
12
|
+
/** The merged config. Default: loadConfig(). */
|
|
13
|
+
cfg?: Config;
|
|
14
|
+
/** Starts the page. Default: startOwnerUi. */
|
|
15
|
+
start?: (opts: OwnerUiOptions) => OwnerUiServer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function runUi(deps: UiDeps = {}): Promise<number> {
|
|
19
|
+
let cfg = deps.cfg;
|
|
20
|
+
if (!cfg) {
|
|
21
|
+
try {
|
|
22
|
+
cfg = loadConfig();
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(err instanceof ConfigError ? err.message : String(err));
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
18
27
|
}
|
|
19
28
|
applyQueueEnv(cfg);
|
|
20
29
|
if (!cfg.ui.enabled) {
|
|
@@ -25,6 +34,8 @@ export function runUi(): number {
|
|
|
25
34
|
console.error("neurastream ui: ui.owner_login is empty — set the tailscale login that may open the page");
|
|
26
35
|
return 1;
|
|
27
36
|
}
|
|
28
|
-
startOwnerUi({ cfg, tailscale: realTailscale, source: defaultRunSource(cfg) });
|
|
29
|
-
|
|
37
|
+
(deps.start ?? startOwnerUi)({ cfg, tailscale: realTailscale, source: defaultRunSource(cfg) });
|
|
38
|
+
// src/cli/main.ts exits with the code this returns, which would kill the server: serving
|
|
39
|
+
// never resolves, and the process runs until systemd or a signal stops it.
|
|
40
|
+
return new Promise<number>(() => {});
|
|
30
41
|
}
|