2023-03-13 11:00:49 +00:00
|
|
|
import * as Metamigo from "@digiresilience/metamigo-common";
|
2023-02-13 12:41:30 +00:00
|
|
|
import { defState } from "@digiresilience/montar";
|
2023-06-02 14:05:20 +00:00
|
|
|
import Manifest from "./manifest.js";
|
|
|
|
|
import config, { IAppConfig } from "../config.js";
|
2023-02-13 12:41:30 +00:00
|
|
|
|
|
|
|
|
export const deployment = async (
|
|
|
|
|
config: IAppConfig,
|
|
|
|
|
start = false
|
|
|
|
|
): Promise<Metamigo.Server> => {
|
|
|
|
|
// Build the manifest, which describes all the plugins needed for our application server
|
|
|
|
|
const manifest = await Manifest.build(config);
|
|
|
|
|
|
|
|
|
|
// Create the server and optionally start it
|
|
|
|
|
const server = Metamigo.deployment(manifest, config, start);
|
|
|
|
|
|
|
|
|
|
return server;
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-13 15:01:40 +00:00
|
|
|
export const stopDeployment = async (server: Metamigo.Server): Promise<void> =>
|
|
|
|
|
Metamigo.stopDeployment(server);
|
2023-02-13 12:41:30 +00:00
|
|
|
|
|
|
|
|
const server = defState("server", {
|
|
|
|
|
start: () => deployment(config, true),
|
|
|
|
|
stop: () => stopDeployment(server),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default server;
|