checkpoint

This commit is contained in:
Rizky 2024-12-20 12:56:27 +07:00
parent 683a050de8
commit d12b850a75
5 changed files with 33 additions and 5 deletions

View File

@ -0,0 +1,5 @@
import { g } from "utils/global";
export const PrasiContent = () => {
return g.mode === "site" ? g.content : null;
};

View File

@ -7,7 +7,7 @@ import { fs } from "utils/fs";
import { g } from "utils/global"; import { g } from "utils/global";
export const loadCurrentDeploy = async (ts: number) => { export const loadCurrentDeploy = async (ts: number) => {
if (fs.exists(`site:deploy/current/${ts}.gz`)) { if (fs.exists(`site:deploy/current/${ts}.gz`) && g.mode === "site") {
await removeAsync(fs.path(`site:deploy/current/files`)); await removeAsync(fs.path(`site:deploy/current/files`));
const content = decode( const content = decode(

View File

@ -1,10 +1,28 @@
import { config } from "utils/config"; import { config } from "utils/config";
import { g, startup } from "utils/global"; import { g, startup } from "utils/global";
import { prasi_content_ipc } from "../content/content-ipc";
import { prasi_content_deploy } from "../content/content-deploy";
import { loadCurrentDeploy } from "../content/deploy/load";
startup("site", async () => { startup("site", async () => {
await config.init("site:site.json"); await config.init("site:site.json");
const ts = config.current?.deploy.current; if (g.mode === "site") {
if (ts) { g.content = g.ipc ? prasi_content_ipc : prasi_content_deploy;
// g.server = process.argv.includes("--ipc") ? "ipc" : "gz";
if (g.ipc) {
} else {
const ts = config.current?.deploy.current;
if (ts) {
await loadCurrentDeploy(ts);
}
}
g.server = Bun.serve({
fetch(request, server) {},
websocket: { message(ws, message) {} },
});
if (g.ipc) {
}
} }
}); });

View File

@ -30,6 +30,8 @@ startup("supervisor", async () => {
if (is_ipc) { if (is_ipc) {
g.mode = "site"; g.mode = "site";
if (g.mode === "site") g.ipc = true; if (g.mode === "site") g.ipc = true;
} else {
} }
startServer({ startServer({

View File

@ -3,6 +3,8 @@ import { join, resolve } from "path";
import type { SiteConfig } from "./config"; import type { SiteConfig } from "./config";
import { fs } from "./fs"; import { fs } from "./fs";
import type { PrasiSpawn, spawn } from "./spawn"; import type { PrasiSpawn, spawn } from "./spawn";
import type { prasi_content_ipc } from "../content/content-ipc";
import type { prasi_content_deploy } from "../content/content-deploy";
if (!(globalThis as any).prasi) { if (!(globalThis as any).prasi) {
(globalThis as any).prasi = {}; (globalThis as any).prasi = {};
@ -15,7 +17,8 @@ export const g = (globalThis as any).prasi as unknown as {
mode: "site"; mode: "site";
server: Server; server: Server;
ipc: boolean; ipc: boolean;
site: { content: typeof prasi_content_ipc & typeof prasi_content_deploy;
site?: {
db?: SiteConfig["db"]; db?: SiteConfig["db"];
layouts: { layouts: {
id: string; id: string;