cnnlabs / cnn-hapi

CNN Hapi
10 stars 4 forks source link

Feature/service start stop #54

Closed codeclout closed 5 years ago

codeclout commented 7 years ago

To test:

adslaton commented 7 years ago

I thought about this further... What is an example use case for this feature?

niahmiah commented 7 years ago

I was wondering the same thing.... hapi plugins already do this

codeclout commented 7 years ago

@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.

codeclout commented 7 years ago

@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.

niahmiah commented 7 years ago

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.

davidlumpkinturner commented 7 years ago

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); `

adslaton commented 7 years ago

Can you demo this to Ian and myself?

jamsyoung commented 5 years ago

Closing, this is over 2 years old and 66% of the people invovled do not work here anymore.