X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworker%2FWorkerUtils.ts;h=943de290800f0b1804e4366da5c2d76ab2d6f28e;hb=0b22144c135af531858c989650e864edb352764d;hp=2b6123514633799c668060ff755e4d7a645394a7;hpb=d3d85b21c808392ead67dd1bba5a7ddc34e2ae0a;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerUtils.ts b/src/worker/WorkerUtils.ts index 2b612351..943de290 100644 --- a/src/worker/WorkerUtils.ts +++ b/src/worker/WorkerUtils.ts @@ -5,9 +5,17 @@ export class WorkerUtils { // This is intentional } + public static async sleep(milliSeconds: number): Promise { + return new Promise((resolve) => setTimeout(resolve as () => void, milliSeconds)); + } + public static defaultExitHandler = (code: number): void => { - if (code !== 0) { - console.error(chalk.red(`Worker exited with error exit code: ${code.toString()}`)); + if (code === 0) { + console.info(chalk.green('Worker exited successfully')); + } else if (code === 1) { + console.info(chalk.green('Worker terminated successfully')); + } else if (code > 1) { + console.error(chalk.red(`Worker exited with exit code: ${code.toString()}`)); } };