2023-03-03 16:23:46 +01:00
|
|
|
import { container } from "tsyringe";
|
2023-10-19 19:21:17 +02:00
|
|
|
|
|
|
|
import { ErrorHandler } from "@spt-aki/ErrorHandler";
|
|
|
|
import { Container } from "@spt-aki/di/Container";
|
|
|
|
import type { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
|
|
|
|
import { App } from "@spt-aki/utils/App";
|
|
|
|
import { Watermark } from "@spt-aki/utils/Watermark";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
export class Program
|
|
|
|
{
|
|
|
|
|
|
|
|
private errorHandler: ErrorHandler;
|
|
|
|
constructor()
|
|
|
|
{
|
|
|
|
// set window properties
|
|
|
|
process.stdout.setEncoding("utf8");
|
|
|
|
process.title = "SPT-AKI Server";
|
|
|
|
this.errorHandler = new ErrorHandler();
|
|
|
|
}
|
|
|
|
|
2023-10-28 21:36:48 +02:00
|
|
|
public async start(): Promise<void>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Container.registerTypes(container);
|
|
|
|
const childContainer = container.createChildContainer();
|
2023-10-28 21:36:48 +02:00
|
|
|
const watermark = childContainer.resolve<Watermark>("Watermark");
|
|
|
|
watermark.initialize();
|
|
|
|
|
2023-03-03 16:23:46 +01:00
|
|
|
const preAkiModLoader = childContainer.resolve<PreAkiModLoader>("PreAkiModLoader");
|
|
|
|
Container.registerListTypes(childContainer);
|
2023-10-28 21:36:48 +02:00
|
|
|
await preAkiModLoader.load(childContainer);
|
|
|
|
|
|
|
|
Container.registerPostLoadTypes(container, childContainer);
|
|
|
|
childContainer.resolve<App>("App").load();
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
2023-10-28 21:36:48 +02:00
|
|
|
catch (err: any)
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
2023-10-28 21:36:48 +02:00
|
|
|
this.errorHandler.handleCriticalError((err instanceof Error ? err : new Error(err)));
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|