ework-aio 0.5.0 → 0.5.2
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 +2 -2
- package/src/commands/lifecycle.ts +33 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ework-aio",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "All-in-one installer for ework (issue tracker) + ework-daemon (AI bridge) + opencode-ework (plugin). One command: npm i -g ework-aio && ework-aio install.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"postinstall": "echo '\\n ework-aio installed. Run \\033[1mework-aio install\\033[0m to set up services.\\n Help: ework-aio --help\\n'"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"ework-daemon": "^0.4.
|
|
49
|
+
"ework-daemon": "^0.4.1",
|
|
50
50
|
"ework-web": "^0.7.0",
|
|
51
51
|
"opencode-ework": "^0.1.0",
|
|
52
52
|
"zod": "^3.23.0"
|
|
@@ -68,6 +68,27 @@ async function loadEnv(envFile: string): Promise<NodeJS.ProcessEnv> {
|
|
|
68
68
|
return env;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
async function readPort(sp: ServicePaths): Promise<number | null> {
|
|
72
|
+
try {
|
|
73
|
+
const content = await Bun.file(sp.envFile).text();
|
|
74
|
+
const portStr = parseEnvFile(content).entries.get(sp.portKey ?? "");
|
|
75
|
+
if (portStr) return Number.parseInt(portStr, 10) || null;
|
|
76
|
+
} catch {
|
|
77
|
+
// missing .env → no port
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function readLogTail(logFile: string, maxLines: number): Promise<string | null> {
|
|
83
|
+
try {
|
|
84
|
+
const text = await Bun.file(logFile).text();
|
|
85
|
+
const lines = text.trimEnd().split("\n");
|
|
86
|
+
return lines.slice(-maxLines).join("\n");
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
async function startOne(
|
|
72
93
|
svc: "web" | "daemon",
|
|
73
94
|
paths: PathConfig,
|
|
@@ -92,7 +113,17 @@ async function startOne(
|
|
|
92
113
|
logFile: sp.logFile,
|
|
93
114
|
pidFile: sp.pidFile,
|
|
94
115
|
});
|
|
95
|
-
|
|
116
|
+
|
|
117
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
118
|
+
if (!isProcessRunning(pid)) {
|
|
119
|
+
const tail = await readLogTail(sp.logFile, 10);
|
|
120
|
+
const detail = tail ? `\n${tail}` : "";
|
|
121
|
+
throw new InstallError(`ework-${svc} failed to start (pid ${pid} exited within 1.5s)${detail}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const port = await readPort(sp);
|
|
125
|
+
const portStr = port !== null ? `, http://127.0.0.1:${port}` : "";
|
|
126
|
+
logger.ok(`ework-${svc} started (pid ${pid}${portStr}, log ${sp.logFile})`);
|
|
96
127
|
return true;
|
|
97
128
|
}
|
|
98
129
|
|
|
@@ -174,20 +205,9 @@ export async function runStatus(opts: GlobalOptions, logger: Logger): Promise<St
|
|
|
174
205
|
const pid = await readPidFile(sp.pidFile);
|
|
175
206
|
const alive = pid !== null && isProcessRunning(pid);
|
|
176
207
|
|
|
177
|
-
let port
|
|
178
|
-
try {
|
|
179
|
-
const content = await Bun.file(sp.envFile).text();
|
|
180
|
-
const portStr = parseEnvFile(content).entries.get(sp.portKey ?? "");
|
|
181
|
-
if (portStr) port = Number.parseInt(portStr, 10) || null;
|
|
182
|
-
} catch {
|
|
183
|
-
// missing .env → no port
|
|
184
|
-
}
|
|
185
|
-
|
|
208
|
+
let port = await readPort(sp);
|
|
186
209
|
let listening: boolean | null = null;
|
|
187
210
|
if (port !== null) {
|
|
188
|
-
// web exposes /login; daemon doesn't. Probe a per-service URL so the
|
|
189
|
-
// status line doesn't lie about the daemon being "not responding"
|
|
190
|
-
// when it's actually healthy.
|
|
191
211
|
const probeUrl = svc === "web"
|
|
192
212
|
? `http://127.0.0.1:${port}/login`
|
|
193
213
|
: `http://127.0.0.1:${port}/`;
|