vercel / micro

Asynchronous HTTP microservices
MIT License
10.59k stars 459 forks source link

Micro stay alive in background even after closing it #407

Closed KASOGIT closed 3 years ago

KASOGIT commented 5 years ago

Hello, every time i close the my server run with nicro it remains alive in the background even if it prompt "gracefully exiting", how can i achieve a complete shutdown of the app ? I can see in the micro bin code that you're juste caching the process exit event and logging a console.log, is this enough ?

function registerShutdown(fn) {
    let run = false;

    const wrapper = () => {
        if (!run) {
                run = true;
                fn(); // registerShutdown(() => console.log('micro: Gracefully shutting down. Please wait...'));
              }
    };

    process.on('SIGINT', wrapper);
    process.on('SIGTERM', wrapper);
    process.on('exit', wrapper);
}
Screenshot 2019-07-11 at 08 46 38 Screenshot 2019-07-11 at 08 51 27
devongovett commented 5 years ago

yeah noticed this as well. I think there needs to be a process.exit() in there somewhere.

carcinocron commented 4 years ago

I'm having the same issue, sudo supervisorctl restart myapp always results in:

micro: Error: listen EADDRINUSE: address already in use 0.0.0.0:10180
    at Server.setupListenHandle [as _listen2] (net.js:1301:14)
    at listenInCluster (net.js:1349:12)
    at doListen (net.js:1488:7)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)