Sagar Anand
Sagar Anand

Reputation: 65

keep nodejs server on azure VM running

I have a Windows Azure VM(linux server 14.04) running and am able to access the VM using command line on my mac/windows machines. I'm running a node.js server and a mongodb instance on this Azure VM.

The problem is that this nodejs server on the VM gets disconnected after sometime(timeout sort of thing). Is it possible that the server on the VM runs indefinitely and keeps serving requests?

PS: My VM is running indefinitely and properly, but the nodejs server on the VM itself times out after sometime. Please help!

Thanks.

Upvotes: 0

Views: 2009

Answers (2)

Gary Liu
Gary Liu

Reputation: 13918

As Azure VMs will not sleep or shutdown itself , and also will not stop any servers running on them. And per your description

the nodejs server on the VM itself times out after sometime

The issue seems the same with what @svenskunganka said.

You can check what occurred the error “sometime”, leveraging PM2 as @Daniel and @svenskunganka suggested.

When you deploy your nodejs project with PM2, it will monitor the application and log errors automatically. You can also monitor your VM metrics (such as CUP Usage,Network in/out) from Azure Portal Monitor panel.

Upvotes: 0

Daniel Conde Marin
Daniel Conde Marin

Reputation: 7742

It is probably just crashing!

A barebone node application does not get monitored by itself. This might sound a little crazy if you come from other web frameworks / platforms like ASP.NET or PHP where you had IIS or Apache monitoring your application for you, which was kind of nice tbh. In node.js you choose your process manager / monitoring system. From my experience, the most popular and well supported PMs are the ones listed in the Expressjs documentation: http://expressjs.com/advanced/pm.html

Upvotes: 2

Related Questions