Node.js deployment to production in windows server - node.js

I'm fairly new with node.js platform.
I'm working on deploying a node.js app to production in windows sever.
Currently I'm using forever for my production server, and pm2 for development server(just to see how different process managers work.)
What I noticed is my app is down after a while (normally couple days).
I think it might be because my user session which runs the process is closed.
Can you share with me the "correct" deployment steps?
The steps I take to deploy are:
1. Run node cmd as administrator
2. Go to site root
3. Run forever start server.js or pm2 start server.js
Thanks in advance.

Related

Node.js app stops working as soon as the AWS Lightsail's Bitnami console is closed

I have developed a simple node.js application and I am trying to publish it on AWS Lightsail. I followed the instructions on this page: https://medium.com/#sharmasha2nk/aws-lightsail-bitnami-nodejs-letsencrypt-cf653573b8a1
I am connecting to Bitnami using the SHH console provided. After I start the app with node index.js command the app is up and running until I close the SHH console. As soon as I close it the application stops and “Service Unavailable” error is being displayed. How can I keep my app running on AWS even if my PC is shot down and the SHH console is closed?
I have tried restarting the apache server and AWS Lightsail instance. Neither of them helped.
httpd-app.conf file content:
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
httpd-prefix.conf file content:
Include "/opt/bitnami/apps/emsnotes/conf/httpd-app.conf"
Thanks.
I would recommend you pm2
Here's how to do it quickly:
install pm2 globally using sudo npm i -g pm2
navigate to the location of your index.js via ssh
run pm2 start index.js
This will keep node running even when you disconnect the ssh session or shutdown your development computer. The process will keep running on your server in the background. This is used for running node apps in production on a server.
You can read all about it here in its documentation.
I hope I could help you, please let me know if you have any question.
Karim
I had a look at the article and frankly i see nowhere that he talk about keeping the server up and running.
Basically he is using the Bitnami Node.js stack and if you look at the docs you will see that Bitnami use Forever.js to keep the apps running on their instance, Forever is a CLI tool to monitor and keep a Node instance running in the background.
Check the docs here : https://docs.bitnami.com/general/infrastructure/nodejs/administration/start-express-server/
Here is the Git for Forever, so can read more on it: https://github.com/foreverjs/forever

how to deploy expressjs application on window server

There many tools to deploy expressjs application, such as strongloop,pm2.
But they do not work well on windows.
I have install [pm2]2 in my window computer, and start my app.
https://i.stack.imgur.com/ZpOIa.jpg
But when i log off my computer and log in again. the service is disappear.
So I install pm2-windows-service and install pm2 as a window service. It failed again.
Anyone have a good expressjs deployment plan?
You need to make a pm2 save when you started your app. PM2 need to know which apps were started and their state to restart them after a reboot, and thats the aim of the pm2 save command which will save the state of all apps in the pm2 directory.

Node App Run Forever?

I have 2 or more node app. That have to run forever if i reboot my PC that i don't want to start server it's automatic start for all node app.I used /ect/init.d node-app file and made some changes it's work but only for one node app but I have to many app on 1 server. Please any on help me.
Here is what you need to do this:
https://github.com/nodejitsu/forever

How can I run my MEANjs app on Digital Ocean permanently?

I've successfully just created a new droplet on Digital Ocean using their MEAN on Ubuntu 14.04 image. I can run my app from the terminal using 'grunt serve' and then view it in the browser at "ip_address:3000". But I still don't understand how I can serve it permanently, by which I mean, keep the app running even after I close my terminal. I've heard of the tool "Forever", but I don't really understand it. Do I even need it or is there another simpler way?
On the command line do:
$ export NODE_ENV=production
will setup production environmental
$ grunt build
will create necessary .min.js and min.css
$ forever start server.js
will load the server with forever, that its a package thats makes sure the node server will restart if an error and will log.
I don't know digital ocean at all, but I can tell you that you are looking for a webserver such as nginx.
The way you are running your server is really just for development purposes. That's why when you close your terminal the application stops execution.
Setting up servers can be its own large task. This is a nodejs nginx example Node.js + Nginx - What now?
You may have to Google for some more specific examples or tutorials on how to do it with digital ocean.
EDIT: you can also run a background process that will not stop executing when you exit the shell session. http://linuxtidbits.wordpress.com/2008/02/01/background-a-process/

how to keep a node server app running on windows server

I'm working on a project and I have modified node.js' 'simple chat room' sample application for my need, it works fine.
I have to call the server app's url (the .js file) to start it before opening the client page in the browser, so far everything works fine. But if the node server app goes down for any reason (server restart, iis restart, etc), the client page returns an error .
My question is, how can I keep the node server app alive all the time even after it interrupted. How can I do that without having a monitor or a script which runs every x minutes.
I'm using IIS 7.5 and iisnode module.
Thanks
Run your script file, as a service, with nssm.
Pretty sure you'll want jesus
Installation
$ npm install -g jesus
Usage
Start monitoring server
$ jesus daemon /path/to/server.log
To start a process
$ jesus start <id> node /path/to/my-app/index.js
To stop one
$ jesus stop <id>
To stop all
$ jesus stopall
I'm not sure about running node in iis. However, you can take a look at the node packages forever, pm2, and nodemon, which will recover the instance in case of failure.
Here's how to install node.js as a service
Here's something on installing node in iis 7.5
Just an update.
I've been using iisnode at work for the better part of a year. I would recommend it if you are deploying to Windows.
https://github.com/isaacs/node-supervisor and https://github.com/remy/nodemon have slightly different feature sets, but aren't Windows specific and still work on Windows unlike many of the other more popular, yet incomplete options such as forever and eternity (as of today anyway).

Resources