Closed rahul-desai3 closed 8 years ago
This is what I see in my Windows terminal (cmd):
E:\cms\client>grunt connect
Running "connect:livereload" (connect) task
Waiting forever...
Started connect web server on http://localhost:9000
The problem is that your grunt tasks run as child processes of cmd.exe, so when you close your terminal, anything that's running within that context is killed. The simplest solution would just be to leave the terminal window open.
How would I do this in the production environment? There I am using CentOS and cant keep the terminal window open.
@rahul-desai3 I don't recommend using this in a production environment (or rather to serve up production assets). It's more for development.
There are a lot of options on npm for managing processes to keep a HTTP server open for production. Check out pm2 or forever.
I even made a video about how to run a node.js server forever: https://www.youtube.com/watch?v=P4mT5Tbx_KE
I installed grunt-contrib-connect using npm and configured Gruntfile.js by adding
grunt.loadNpmTasks('grunt-contrib-connect');
and thekeepAlive
flag in connect > options.When I run it using
grunt connect
, my site works fine however, if I close the terminal, the site doesnt stay alive. In Chrome, I getERR_CONNECTION_REFUSED
if I try to access it.Here is my complete Gruntfile.js: https://gist.github.com/rahul-desai3/a7a078181488e7b7bf1d
How do I fix this?