-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: add support for SIGINT on Windows (fixes issue #1720) #1853
Conversation
This commit adds an install script that runs on 'npm install'. Its purpose is to download, extract and verify a specific version of the windows-kill.exe binary. I decided not add the - windows only - executable directly to this project to keep the dependencies clear. Furthermore I did not use the node-window-kill package, because it comes with node-gyp which requires python and vs2017 build tools on the target machine.
This commit replaces the taskkill invocation with windows-kill.exe. We are now sending a SIGINT POSIX signal to the node process in a Windows context. Known issues: The windows-kill.exe has to be triggered in a detached process context, which currently flashes a terminal window on each reload. Furthermore the 'restart' event is triggered twice on the bus.
This commit silences all errors from the wmic.exe process. Which is save, because the error case is handled by falling back to the child.pid. It also optimizes the windows-kill invocation by minimizing (hiding) the terminal window and keeping it open until the process has finished.
…1720) This commit replaces the provisioning script, which downloaded a specific windows-kill.exe binary, with the binary itself. We are using the x64 version of the windows-kill.exe from: https://github.com/ElyDotDev/windows-kill/releases/tag/1.1.4 We are now embedding the binary with the project directly to decrease the complexity and avoid breaking the build by external changes. Actually the maintainer of windows-kill changed his GitHub username recently from "alirdn" to "ElyDotDev" which broke the provisioning script!
I've published a debug build to npm - Really great work seeing this through 👍 |
This commit adds back the hard shutdown behaviour under Windows as an opt-in: If the --signal option is "SIGKILL" nodemon will terminate the process group by force without waiting for the process to clean-up. This matches a SIGKILL on a UNIX system.
|
Right, this has been quiet for a bit, but let's ship this - I reckon it'll help those windows users - I've seen quite a few similar issues recently so hopefully this nails it. Really excellent work @countzero |
FFS - something has gone weird on travis - so this isn't actually live, so I'll need to fix whatever has happened then this will be live. |
🎉 This PR is included in version 2.0.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I get this with the latest version. The system cannot find the file C:\Projects\node.js\complete-node-bootcamp\4-natours\starter\node_modules\nodemon\bin\windows-kill.exe. I've initially installed nodemon globally, without adding it to the project dependencies. I've fixed this by doing a npm i nodemon --save-dev too. Shouldn't it work by installing it globally only? It did before. |
@RepentAndBelieveTheGospel issue being tracked here: #1872 |
@remy Sorry, didn't check the opened issues. |
I'm not well-versed on Windows system and binaries, and I know compiling it is too much hassle for users. But can we have the source to the executables? |
@bentinata I believe the source code is from: |
This adds a
windows-kill.exe
binary which handles the sending of the POSIX signalSIGINT
on Windows.The repository https://github.com/countzero/nodemon_windows_kill contains a a cross-platform compatible test to quickly verify the correct behaviour of this fix.