gimm / gulp-express

gulp plugin for express
56 stars 26 forks source link

Why do you use SIGKILL? #34

Open vid opened 9 years ago

vid commented 9 years ago

It's not trappable. I would like to close database connections before restarting.

http://nodejs.org/api/process.html#process_signal_events

thanks!

gimm commented 9 years ago

just want to kill the child_process. Don't know much about nodejs signals here, any better suggestion here?

vid commented 9 years ago

You should be able to use a milder signal like SIGHUP.

gimm commented 9 years ago

@vid I had error with SIGHUP, I'm running node v0.10.36 on win7. As far as I know, I need to kill this child_process, and SIGKILL works for me.

What do you mean by "close database connections before restarting", what API do you want? A callback for server.stop ?

vid commented 9 years ago

Have you tried SIGINT, per the process page above? If necessary you could detect the OS if you'd like your module to be cross platform.

I mean my app opens a connection to the database and should properly close it before restarting, as would any well behaved app.

gimm commented 9 years ago

No dice with SIGINT. I'm searching for a way to kill the child process while being able to catch it in the script(app.js), so that we can do some cleanup in app.js before it was killed.

cybrown commented 9 years ago

+1, I'm building a workflow with a watcher on js files and it would be nice if the script does not exit when there is an error in the child process

gimm commented 9 years ago

please use https://github.com/gimm/gulp-live-server instead of gulp-express, I'll apply your change to gulp-live-server soon

cybrown commented 9 years ago

Thanks :)