wip fix
This commit is contained in:
parent
f23a97f948
commit
94caebd289
|
|
@ -1,11 +1,12 @@
|
||||||
import { Subprocess, spawn } from "bun";
|
import { spawn } from "bun";
|
||||||
import { SAction } from "../actions";
|
import { ExecaChildProcess, $ } from "execa";
|
||||||
import { SyncConnection } from "../type";
|
|
||||||
import { code } from "../editor/code/util-code";
|
|
||||||
import { waitUntil } from "web-utils";
|
import { waitUntil } from "web-utils";
|
||||||
|
import { SAction } from "../actions";
|
||||||
|
import { code } from "../editor/code/util-code";
|
||||||
|
import { SyncConnection } from "../type";
|
||||||
|
|
||||||
const code_startup = {
|
const code_startup = {
|
||||||
process: {} as Record<string, Subprocess>,
|
process: {} as Record<string, ExecaChildProcess>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const code_action: SAction["code"]["action"] = async function (
|
export const code_action: SAction["code"]["action"] = async function (
|
||||||
|
|
@ -36,18 +37,9 @@ export const code_action: SAction["code"]["action"] = async function (
|
||||||
case "startup-run": {
|
case "startup-run": {
|
||||||
const cs = code_startup.process[arg.site_id];
|
const cs = code_startup.process[arg.site_id];
|
||||||
if (!cs || (cs && cs.killed)) {
|
if (!cs || (cs && cs.killed)) {
|
||||||
code_startup.process[arg.site_id] = spawn({
|
code_startup.process[arg.site_id] = $({
|
||||||
cmd: ["npm", "run", "startup"],
|
|
||||||
cwd: code.path(arg.site_id, "site", "src"),
|
cwd: code.path(arg.site_id, "site", "src"),
|
||||||
stdin: "inherit",
|
})`npm run startup`;
|
||||||
stdout: "inherit",
|
|
||||||
stderr: "inherit",
|
|
||||||
});
|
|
||||||
code_startup.process[arg.site_id].exited.then((exitCode) => {
|
|
||||||
console.log(
|
|
||||||
`startup script site id ${arg.site_id}, exited: ${exitCode}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
await waitUntil(1000);
|
await waitUntil(1000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -56,7 +48,7 @@ export const code_action: SAction["code"]["action"] = async function (
|
||||||
const cs = code_startup.process[arg.site_id];
|
const cs = code_startup.process[arg.site_id];
|
||||||
if (cs && !cs.killed) {
|
if (cs && !cs.killed) {
|
||||||
cs.kill();
|
cs.kill();
|
||||||
await cs.exited;
|
await waitUntil(1000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue