express - Starting Node.js server without console -
okay, noob question, i'm starting node.js , i've noticed tutorials tell this:
app.listen(3000); console.log('listening on port 3000');
to start server. works fine testing on local host, requires me use console start server typing node server.js
in production enviroment how manage this? i'm sure don't have use program putty tunnel in , start server. can explain me? i'm using node.js latest build express web framework.
thanks
unless use fancy platform amazon's aws elastic beanstalk or heroku, in production environment still have have sort of console access (ssh) log in server, , upload , start application. need ensure app runs continuously background service, , gets restarted if crashes.
there utilities node that, forever.
with forever, this:
$ git clone git://gitserver:myapp.git $ cd myapp $ npm install $ sudo npm install -g forever $ forever start server.js
this leaves server.js running daemon in background , can close ssh. see daemons running , logs can run:
$ forever list $ forever logs 0
the app still run on port 3000, may want configure reverse proxy server redirect port 80, nginx, example.
Comments
Post a Comment