-
-
Save rivy/5027109d81e57590cea442eff1b952fd to your computer and use it in GitHub Desktop.
Handling Ctrl-C cleanly in Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show how to handle Ctrl+C in Node.js | |
var zmq = require('zmq') | |
, socket = zmq.createSocket('rep'); | |
socket.on('message', function(buf) { | |
// echo request back | |
socket.send(buf); | |
}); | |
process.on('SIGINT', function() { | |
socket.close(); | |
process.exit(); | |
}); | |
socket.bindSync('tcp://*:5555'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment