📁 Changed TDrive root folder (#16)

📁 Changed TDrive root folder
This commit is contained in:
Montassar Ghanmy
2023-04-11 10:04:29 +01:00
committed by GitHub
parent 3b3f67af07
commit e0615fa867
10548 changed files with 48 additions and 48 deletions
+62
View File
@@ -0,0 +1,62 @@
import path from "path";
import { TdrivePlatform, TdrivePlatformConfiguration } from "./core/platform/platform";
import globalResolver from "./services/global-resolver";
/**
* Instantiate and start a new TdrivePlatform with the given services.
*/
async function run(services: string[] = []): Promise<TdrivePlatform> {
let platform: TdrivePlatform;
const start = async (): Promise<TdrivePlatform> => {
try {
const configuration: TdrivePlatformConfiguration = {
services,
servicesPath: path.resolve(__dirname, "./services/"),
};
platform = new TdrivePlatform(configuration);
await platform.init();
await platform.start();
await globalResolver.doInit(platform);
return platform;
} catch (err) {
console.error("Will exit process because of: ", err);
process.exit(-1);
}
};
async function stop() {
try {
await platform?.stop();
} catch (err) {
console.error(err);
}
}
process.on("uncaughtException", error => {
console.error(error);
});
process.on("unhandledRejection", error => {
console.error(error);
});
process.on("SIGINT", async () => {
await stop();
process.kill(process.pid, "SIGUSR2");
});
process.once("SIGUSR2", async () => {
await stop();
process.kill(process.pid, "SIGUSR2");
});
await start();
return platform;
}
export default {
run,
};