Add simple launcher

This commit is contained in:
Merijn Hendriks 2021-12-26 18:17:43 +01:00
parent 4e8b92fc52
commit c91a3578c3
5 changed files with 46 additions and 9 deletions

View File

@ -0,0 +1,11 @@
export class ServerConfig
{
public backendUrl: string;
public version: string;
constructor(backendUrl: string = "http://localhost:8000", version: string = "live")
{
this.backendUrl = backendUrl;
this.version = version;
}
}

View File

@ -0,0 +1,29 @@
import { exec, ExecException } from "child_process";
import { Json, Log } from "../common/Haru.Utils";
import { ServerConfig } from "./Haru.Eft.Models";
export class GameStarter
{
public static run(): void
{
const sessionId = "haru-singleplayer"
const serverConfig = Json.serialize(new ServerConfig());
exec(`EscapeFromTarkov.exe -force-gfx-jobs native -token=${sessionId} -config=${serverConfig}`, GameStarter.onLaunch);
}
private static onLaunch(error: ExecException | null, stdout: string, stderr: string): void
{
if (error)
{
throw error;
}
Log.write(stdout);
GameStarter.exitSuccess();
}
private static exitSuccess(): void
{
process.exit(0);
}
}

View File

@ -1,14 +1,11 @@
import { Log } from "../common/Haru.Utils"; import { Log } from "../common/Haru.Utils";
import { GameStarter } from "./Haru.Launcher";
export class Program export class Program
{ {
public static main(args: string[]) public static main(args: string[])
{ {
Log.init("./Logs/Haru.log"); Log.init("./Logs/Haru.log");
GameStarter.run();
for (const command of args)
{
Log.info(command);
}
} }
} }

View File

@ -1,7 +1,7 @@
import { PingNotification } from "./Haru.Eft.Models";
import { CachedResponseService, CachedResponseHelper, FileResponseHelper, FileService } from "./Haru.Eft.Services";
import { HttpServer, WsServer, IServer } from "../common/Haru.Http"; import { HttpServer, WsServer, IServer } from "../common/Haru.Http";
import { Json } from "../common/Haru.Utils"; import { Json } from "../common/Haru.Utils";
import { PingNotification } from "./Haru.Eft.Models";
import { CachedResponseService, CachedResponseHelper, FileResponseHelper, FileService } from "./Haru.Eft.Services";
export class ServerCluster export class ServerCluster
{ {

View File

@ -1,7 +1,7 @@
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "http";
import { CheckVersionResponse, FriendList, KeepAliveResponse, LogoutResponse, ResponseBody, ServerInfo } from "./Haru.Eft.Models";
import { Json } from "../common/Haru.Utils";
import { Service } from "../common/Haru.Http"; import { Service } from "../common/Haru.Http";
import { Json } from "../common/Haru.Utils";
import { CheckVersionResponse, FriendList, KeepAliveResponse, LogoutResponse, ResponseBody, ServerInfo } from "./Haru.Eft.Models";
export class FileResponseHelper export class FileResponseHelper
{ {