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