Closed nicroto closed 9 years ago
Using searchcode.com I found another project using the grunt-express-server and watch.
I stole this trick and now I am not blocked:
var server = http.createServer(app).listen(PORT, function() {
console.log('Express server listening on port ' + PORT);
});
Now I get what you meant by:
By default, unless delay or output has been customized, the server is considered "running" once any output is logged to the console, upon which control is passed back to grunt.
But this doesn't tell me that my code is responsible for logging something in the terminal. And in my case - it wouldn't work, because I am currently just serving a static website. So my watch will not be working while I change the content to be served (which is regenerated by that same watch), because my server will not be logging anything in the terminal.
I will send a pull request with some additional explanation, promptly. But this probably must be improved in general with some other way to detect that the server is up.
Thank you for the useful module.
Here is my pull request with proposed change in the docs #75.
P.S.
The PR was accepted.
Hi guys, I just run into the same problem described here and even though I followed the instructions, I couldn't the it working. After a few cycles of trying and revising everything I found out that it does not work if you have background: false in you express task.
express: {
dev: {
options: {
port: 3000,
background: false,
script: './index.js'
}
}
},
Hi,
I am having trouble getting express and watch running concurrently. The idea is to restart the server anytime the code has changed.
First of all, the express task doesn't start a server on port 5000. Why is that? And secondly, watch can't be started after express begins.
Here is my watch and express configs and the composite task:
And this is the server.js:
And this is the output from running 'dev':
I think the problem comes from the inability to actually start the server -> then it can detect a server started -> can't move on to the next grunt task. But why doesn't it start the server?
Thanks.