Conditional start of server


#1

I want to pre validate some conditions and only if all pass through i want to start the server or else stop the server with the message.

I tried implemention it in start/hooks.js ==> hooks.before.httpServer(async () => {
if(conditionFails) {
throw Error(“Condition fails server stopping”)
}
}

but even after throwing the error, server continue to start.

any ideas on how to implement it.

Thanks,
Sujai.K


#2

Does this help https://stackoverflow.com/questions/17958618/how-do-i-stop-a-node-js-http-server-programmatically-such-that-the-process-exits