Closed codeclout closed 5 years ago
I thought about this further... What is an example use case for this feature?
I was wondering the same thing.... hapi plugins already do this
@niahmiah - correct this feature simply exposes the onPreStart
and onPostStop
events to the services
property of the config. Essentially you'd pass an array of objects where each object would contain a start
and stop
method that would be called at the appropriate time.
@adslaton - an example would be if I wanted to create a db connection before connections to hapi were allowed, I'd pass that logic as the start method and closing that connection as the stop method.
I still don't understand. This seems to imply that your services are not hapi plugins. Why would we use hapi that way?
I will defer to AD for approval.
the basis for this makes sense to me. being able to control start and stop of hapi along with other services is something that we should be doing on our apps. for example, consider this lib being used as a part of different app.
` db.start() .then(() => { redis.start(); }) .then(() => { hapi.start(); });
function stopServices() { hapi.stop() .then(() => { redis.stop(); }) .then(() => { db.stop(); process.exit(); }) }
process.on('SIGINT', stopServices);
process.on('SIGTERM', stopServices); `
Can you demo this to Ian and myself?
Closing, this is over 2 years old and 66% of the people invovled do not work here anymore.
To test:
spin up a standalone Redis process
spin up the example app
you should see the redis connection take place
onPreStart
(called before the connection listeners are started)send the
SIGINT
eventthe redis connection should quit
onPostStop
(called after the connection listeners are stopped)