2022-10-24 11:51:26 +00:00
|
|
|
import { path } from "../server/deps.ts";
|
|
|
|
import { HttpServer } from "../server/http_server.ts";
|
|
|
|
import assetBundle from "../dist/asset_bundle.json" assert { type: "json" };
|
|
|
|
import { AssetBundle, AssetJson } from "../plugos/asset_bundle/bundle.ts";
|
|
|
|
|
|
|
|
export function serveCommand(options: any, folder: string) {
|
|
|
|
const pagesPath = path.resolve(Deno.cwd(), folder);
|
|
|
|
const port = options.port || 3000;
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
"Going to start Silver Bullet on port",
|
|
|
|
port,
|
|
|
|
"serving pages from",
|
|
|
|
pagesPath,
|
2022-11-26 13:15:38 +00:00
|
|
|
"with db file",
|
|
|
|
options.db,
|
2022-10-24 11:51:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const httpServer = new HttpServer({
|
|
|
|
port: port,
|
|
|
|
pagesPath: pagesPath,
|
2022-11-26 13:15:38 +00:00
|
|
|
dbPath: path.join(pagesPath, options.db),
|
2022-10-24 11:51:26 +00:00
|
|
|
assetBundle: new AssetBundle(assetBundle as AssetJson),
|
|
|
|
password: options.password,
|
|
|
|
});
|
|
|
|
httpServer.start().catch((e) => {
|
2022-11-25 12:08:59 +00:00
|
|
|
console.error("HTTP Server error", e);
|
|
|
|
Deno.exit(1);
|
2022-10-24 11:51:26 +00:00
|
|
|
});
|
|
|
|
}
|