amazon ec2 - How do I leave Node.js server on EC2 running forever? -
as can tell question, i'm new this...
i built first website, set first node.js server serve , pushed live on ec2.
i tested on ec2 ip address , seems working.
now until now, i've been testing app locally makes sense whenever closed terminal, app.js stop running nil served on localhost.
now server on ec2, same thing happens ("obviously" 1 say..) whenever close terminal.
so question how maintain node.js server running on ec2 like... forever..so site stays live.. forever :)
i read node module called "forever" i'm wondering (being new , all..) why isn't "forever" functionality default setting of node.js-ec2 scheme ?
i mean, right me if i'm wrong, isn't whole point of setting web server , pushing live have remain live forever? isn't servers supposed anyway (infinitely listening requests) ? , if that's case why need modules/settings accomplish ?
thanks help.. can tell i'm not looking solution explanation because got confused.. :-)
edit (a few details might need) - after installing app on ec2 these steps follow on terminal (the app running on amazon linux
way) :
i type ssh -i xxxxxxxxxxx.pem ec2-user@ec2-xx-xx-xx-x.eu-west-1.compute.amazonaws.com on terminal
after logging onto amazon machine go relevant folder , execute node app.js
there 3 folders in machine : node
, node_modules
, *name of app*
app.js
resides in *name of app*
after that, site goes live on ec2 ip
once close terminal, switched off
before invoke node.js, run command:
screen
this create persistent environment allow process maintain running after disconnect.
when reconnect, can utilize screen -r reconnect environment.
here's random link larn more screen:
http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
however, won't help if ec2 instance restarts. there many different ways that. adding startup command /etc/rc.local 1 way. here's link amazon guide includes adding /etc/rc.local.
http://docs.aws.amazon.com/awsec2/latest/userguide/building-shared-amis.html
hope helps,
james
node.js amazon-ec2 webserver
No comments:
Post a Comment