ProcessUtils¶
ProcessUtils.initEnvFromDefaultFiles()¶
This utility class includes a simple implementation for runtime .env
file support.
import ProcessUtils from "./fi/hg/core/ProcessUtils";
// Must be first import to define environment variables before anything else
ProcessUtils.initEnvFromDefaultFiles();
ProcessUtils.setupDestroyHandler(shutdownHandler, errorHandler)¶
This utility function can be used to implement default shutdown handlers for the common runtime events.
It will hook into events exit
, SIGTERM
, SIGINT
, SIGUSR1
, SIGUSR2
and uncaughtException
.
The shutdownHandler
will be called only once.
If an exception is thrown, the errorHandler
will be called with the exception.
import ProcessUtils from "./fi/hg/core/ProcessUtils";
const server = new Server();
server.start();
ProcessUtils.setupDestroyHandler( () => {
server.stop();
}, (err : any) => {
LOG.error('Error while shutting down the service: ', err);
});