onApplicationBootstraponApplicationBootstrap is called after every module has been initialised, before the app listens for connections.
"onModuleInit" is wrong. It runs earlier, once the host module's dependencies are resolved, so other modules may not be ready yet. "beforeApplicationShutdown" and "onApplicationShutdown" run when the app is shutting down.
Read more