STEP 1:
Install NodeJs on the cloud server,
apt-get install nodejs.
check version by npm -v
STEP 2:
Transfer Code?repo Unto Cloud Server using WinSCP or other ssh third part apps
STEP 3:
Navigate to the folder where the nodejs code is and do a
node filename.js
and what do u see?
STEP 4:
So i tried to consume my new service on my 'borrowed ' cloud server. And it didnt work!!!! after so much happiness?This is spiritual! So i found out putty had closed connection and hence closed session to the server hence the unavailability to reach Server. So i wanted it to run forever. i searched and found this wonderful script. Wonderful,
noHup nodejs filename.js &That worked for a while until my mochahost server decided to do a maintenance on a weekend. They did and they didnt start up my server. Crazy abi? Was i expecting them to before? So i wanted a solution. So i searched further. Got another called
ForeverForever does the Job perfectly, restarts your server incase of 'iranu'(errors).
STEP 5:
Install forever using sudo apt-get install forever --global
DONE!!! But it doesnt recognize the NodeJs used as keyword hence it reports 'file not found' on doing a 'forever list'. So i found an alternative.
Install node-legacy by: sudo apt-get install nodejs-legacy That fixed it. So Forever has a couple of operands: Three most important ones are : start, stop and list.
LIST lists all the processes being run by the forever service;
Look at the circled red stuff, That is the process id;
This can also be achieved by using the
'ps aux| grep nodejs'
STOP as usual stops the process i.e
'forever stop [process_id]',
equivalent to the kill -9 [ubuntuprocess_id]
START: Starts a forever process for the nodeJs server 'forever start filename.js'
Voila! You have Set Up That Server. !!
No comments:
Post a Comment