Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send SIGUSR2 signal on restart like nodemon? #21

Closed
ericf opened this issue Aug 9, 2017 · 5 comments
Closed

Send SIGUSR2 signal on restart like nodemon? #21

ericf opened this issue Aug 9, 2017 · 5 comments

Comments

@ericf
Copy link

ericf commented Aug 9, 2017

Would it be possible to add a some signal, e.g. SIGUSR2 before a restart to allow a micro server to perform some cleanup? nodemon does this: https://github.com/remy/nodemon/#controlling-shutdown-of-your-script

My use-case is a setInterval() that I want to call clearInterval() on each time micro-dev restarts the server. Right now I end up with one interval long running for every single start/restart of the server.

@leo
Copy link
Contributor

leo commented Aug 9, 2017

That sounds sweet!

@leo
Copy link
Contributor

leo commented Aug 10, 2017

The thing is that we're not killing the process, but rather removing some cached files from memory and then loading the server again (which is much faster). In turn, the user wouldn't be able to handle the restart by himself. Or maybe we should send a function to call after cleanup along with the event?

@Kikobeats
Copy link
Member

@laduke
Copy link

laduke commented Sep 14, 2017

I have a similar use-case where I have a readstream open and when micro-dev reloads, another stream starts and the existing one doesn't get killed. I think that's what happens, anyways; The code runs number-of-restarts times.

I guess you'd need to have dev env only related code in your service then to handle cleaning up stuff like this, which I'm not sure you'd want.

A thing that might be nice is a "cold reloading" switch, but just using nodemon with micro-dev -c achieves the same thing.

Very contrived example:

process.stdin.pipe(process.stdout)

module.exports = (req, res) => {
  res.end('OK!')
}

(type something into the same terminal micro-dev is running in and press enter. resave. repeat)

@leo
Copy link
Contributor

leo commented Oct 24, 2017

Added in #48

@leo leo closed this as completed Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants