简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM