lundi 7 juillet 2014

Node.js server.listen callback?


Vote count:

0




I have a node.js application and I need to run a command once the server starts listening. The docs on server.listen say:

server.listen(port, [hostname], [backlog], [callback])

but when I try to use this format, the code is not run, but no error messages are appearing. Here is the listening part of my application:



var spawn = require('child_process').spawn
function listen(port) {
try {
server.listen(port, "localhost",511, function() {
spawn("open",["http://localhost:"+port+"/"])
})
} catch (e) {
listen(port+1)
}
}


Thanks,

Vulpus



asked 19 secs ago

Vulpus

635





Aucun commentaire:

Enregistrer un commentaire