2023-01-31 22:00:30 -05:00
|
|
|
import * as toml from 'toml';
|
2023-02-02 21:19:55 -05:00
|
|
|
import IConfig from './IConfig.js';
|
2023-01-31 22:00:30 -05:00
|
|
|
import * as fs from "fs";
|
2023-02-02 21:19:55 -05:00
|
|
|
import WSServer from './WSServer.js';
|
|
|
|
|
import QEMUVM from './QEMUVM.js';
|
2023-01-31 22:00:30 -05:00
|
|
|
|
|
|
|
|
// Parse the config file
|
|
|
|
|
|
|
|
|
|
var Config : IConfig;
|
|
|
|
|
|
|
|
|
|
if (!fs.existsSync("config.toml")) {
|
|
|
|
|
console.error("config.toml not found. Please copy config.example.toml to config.toml and fill out fields.");
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
var configRaw = fs.readFileSync("config.toml").toString();
|
|
|
|
|
Config = toml.parse(configRaw);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(`Failed to read or parse the config file: ${e}`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-02-02 21:19:55 -05:00
|
|
|
async function start() {
|
|
|
|
|
// Fire up the VM
|
|
|
|
|
var VM = new QEMUVM(Config);
|
|
|
|
|
await VM.Start();
|
|
|
|
|
|
|
|
|
|
// Start up the websocket server
|
|
|
|
|
var WS = new WSServer(Config, VM);
|
|
|
|
|
WS.listen();
|
|
|
|
|
}
|
|
|
|
|
start();
|