checkpoint
This commit is contained in:
parent
240d4e6ec1
commit
e847a8d747
|
|
@ -14,6 +14,7 @@ export const prasi_content_deploy: PrasiContent = {
|
||||||
await loadCurrentDeploy(ts);
|
await loadCurrentDeploy(ts);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async started() {},
|
||||||
async staticFile(ctx) {},
|
async staticFile(ctx) {},
|
||||||
async route(ctx) {},
|
async route(ctx) {},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ export const prasi_content_ipc: PrasiContent = {
|
||||||
if (g.mode === "site" && g.ipc) {
|
if (g.mode === "site" && g.ipc) {
|
||||||
if (msg.type === "start") {
|
if (msg.type === "start") {
|
||||||
g.ipc.asset = await staticFile(msg.path.asset);
|
g.ipc.asset = await staticFile(msg.path.asset);
|
||||||
ipcSend({ type: "ready", port: g.server.port });
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,6 +28,11 @@ export const prasi_content_ipc: PrasiContent = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
async started() {
|
||||||
|
if (g.mode === "site" && g.server) {
|
||||||
|
ipcSend({ type: "ready", port: g.server.port });
|
||||||
|
}
|
||||||
|
},
|
||||||
async staticFile(ctx) {
|
async staticFile(ctx) {
|
||||||
const asset = g.mode === "site" && g.ipc?.asset!;
|
const asset = g.mode === "site" && g.ipc?.asset!;
|
||||||
if (asset) {
|
if (asset) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { g } from "utils/global";
|
import { g } from "utils/global";
|
||||||
|
|
||||||
export const prasiContent = () => {
|
export const prasiContent = () => {
|
||||||
return g.mode === "site" ? g.content : null;
|
return g.mode === "site" ? g.prasi : null;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import type { ServerCtx } from "utils/server-ctx";
|
||||||
export type PrasiContent = {
|
export type PrasiContent = {
|
||||||
prepare: (site_id: string) => void | Promise<void>;
|
prepare: (site_id: string) => void | Promise<void>;
|
||||||
init: () => Promise<void>;
|
init: () => Promise<void>;
|
||||||
|
started: () => Promise<void>;
|
||||||
staticFile: (ctx: ServerCtx) => Promise<Response | void>;
|
staticFile: (ctx: ServerCtx) => Promise<Response | void>;
|
||||||
route: (ctx: ServerCtx) => Promise<Response | void>;
|
route: (ctx: ServerCtx) => Promise<Response | void>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,16 @@ import { prasi_content_ipc } from "../content/content-ipc";
|
||||||
startup("site", async () => {
|
startup("site", async () => {
|
||||||
await config.init("site:site.json");
|
await config.init("site:site.json");
|
||||||
if (g.mode === "site") {
|
if (g.mode === "site") {
|
||||||
g.content = g.ipc ? prasi_content_ipc : prasi_content_deploy;
|
g.prasi = g.ipc ? prasi_content_ipc : prasi_content_deploy;
|
||||||
|
|
||||||
const content = g.content;
|
const prasi = g.prasi;
|
||||||
await content.init();
|
await prasi.init();
|
||||||
startGlobalServer();
|
await startSiteServer();
|
||||||
|
await prasi.started();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const startGlobalServer = async () => {
|
const startSiteServer = async () => {
|
||||||
if (g.mode === "site") {
|
if (g.mode === "site") {
|
||||||
g.server = Bun.serve({
|
g.server = Bun.serve({
|
||||||
async fetch(req, server) {
|
async fetch(req, server) {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export const g = (globalThis as any).prasi as unknown as {
|
||||||
asset?: StaticFile;
|
asset?: StaticFile;
|
||||||
};
|
};
|
||||||
static_cache: any;
|
static_cache: any;
|
||||||
content: typeof prasi_content_ipc & typeof prasi_content_deploy;
|
prasi: typeof prasi_content_ipc & typeof prasi_content_deploy;
|
||||||
site?: {
|
site?: {
|
||||||
db?: SiteConfig["db"];
|
db?: SiteConfig["db"];
|
||||||
layouts: {
|
layouts: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue