import Configuration from '../utils/Configuration';
import { StationWorkerData } from '../types/Worker';
import Utils from '../utils/Utils';
+import WorkerAbstract from '../worker/WorkerAbstract';
import WorkerFactory from '../worker/WorkerFactory';
-import Wrk from '../worker/Wrk';
import { isMainThread } from 'worker_threads';
+import path from 'path';
export default class Bootstrap {
private static instance: Bootstrap;
private started: boolean;
private workerScript: string;
- private workerImplementationInstance: Wrk;
+ private workerImplementationInstance: WorkerAbstract;
private constructor() {
this.started = false;
- this.workerScript = './dist/charging-station/StationWorker.js';
+ this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'StationWorker.js');
}
public static getInstance(): Bootstrap {
for (let index = 1; index <= nbStations; index++) {
const workerData: StationWorkerData = {
index,
- templateFile: stationURL.file
+ templateFile: path.join(path.resolve(__dirname, '../'), 'assets', 'station-templates', path.basename(stationURL.file))
};
await this.getWorkerImplementationInstance().addElement(workerData);
numStationsTotal++;
await this.start();
}
- private getWorkerImplementationInstance(): Wrk {
+ private getWorkerImplementationInstance(): WorkerAbstract {
if (!this.workerImplementationInstance) {
this.workerImplementationInstance = WorkerFactory.getWorkerImplementation<StationWorkerData>(this.workerScript, Configuration.getWorkerProcess(), {
poolMaxSize: Configuration.getWorkerPoolMaxSize(),