Node Server does not automatically restarts after deployment on Google App Engine - node.js

I have a NodeJS Application that I deploy on Google App Engine Platform. Everything was working fine till last week. But now whenever I deploy the application on Gcloud app engine, the server does not get automatically restart. I always have to stop the instance and start it again to restart the server to serve the latest deployed code. I have 4 different servers and this is happening with each one of them. I don't think this is related to some code that I have in my application. I am using a paid plan of Google Cloud Platform.
Any help on this will be highly appreciated.

Related

JHipster and Google Cloud Platform

I've just deployed a cluster on google cloud platform kubernete engine using JHipster. The deploy worked fine and the main application starts, but the underground microservices doesn't work. I always have an "Internal server error" when i click on a button that calls a microservices. I tried to allow visibility between nodes but it still doesn't work. Do you have any idea? Thanks

how to run a node server in an azure virtual machine permanently?

I build a web based mobile app (using react), which I'm hosting as an Azure Web app. This website is connected to a node server, which I'm hosting using a azure virtual machine (I don't know if this is the best approach, maybe I should host this as a webapp instead of VM ?).
I'm still new to this strategie of developing a web based mobile app and connecting it to a hosted backend in the cloud so I apologize if this is a trivial question.
I'm using websockets to connect my frontend to the node server and then I consume messages. I don't have a database it is a simple application.
The steps I'm doing to run the app are:
I connect to the Azure VM from my laptop with ssh
run my server using node server.js
When the server is runing, I can refresh my website and everything works fine
Now, the problem is that I want the node server to run all the time. However, I noticed that the server stops running when I deconnect (ssh) my laptop from the virtual machine. So I find myself doing these steps (connecting to the VM with ssh and running the server manually) each time I want to use the app.
Is there a way to do this so that the node server runs all the time without stoping? Also since I'm new to this, is this the right way to deploy frontend and backend? I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
(Since part of your question is around "Is there a better way?", I would answer that instead of fixing the issue in your current VM hosting :)).
To take full advantage of cloud for your applications, PaaS is always preferred over IaaS. In this case, unless you have any specific reason, you should deploy your backend Node app in another App Service (aka Web App). Or you can consider Azure Function also if your node app has a small set of APIs, but it will require code update. Both support multiple platforms including node.js. Since you mentioned you are leveraging Web App for your react mobile app, so I hope you are already bit familiar with it. Also since Azure Function would require code change, so Web App is preferred this case.
Note: I omitted other solutions like AKS, Service Fabric etc. for now, since currently we are talking about the problem of deploying only a single app, for which those will be overkill at this moment.
Also, to your point
I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
Yes technically you can, depending on your scenario by "bundling" into a single app if both are in same platform (like Node in this case). Though whether one should do that would be an opinionated answer. But even if you keep those separate, you can still leverage single App Service Plan for cost saving. So keeping separate like you have now is what I would suggest to maintain "separation of concern".

Azure : Deploy Angular(Front-End) & Node (Back-End) app without VM

I am new to Azure. I have never used azure. So don't mind if this is some silly question.
I have a client who also doesn't know much about deploying.
I have angular/node apps. He wants to host on Azure WITHOUT using a VM.
I am not sure about azure. So i don't know how to deploy without VM.
I know to deploy with RDP(Remote Desktop).
Can anyone help me with this. Is there a way to deploy angular & node app without VM?
Is there any specific documentation for it? Which services will i need in Azure?
Thanks in advance!
Except Azure VM, there are normally two ways to deploy Node.js app on Azure which include App Service - Web Apps and Web Apps for Containers, please see the links below to know these guides.
For deploying Node.js app on Azure Web Apps.
Create a Node.js web app in Azure
Tutorial: Build a Node.js and MongoDB web app in Azure
To deploy the app with a ZIP file, or via FTP, cloud sync, or deploy continuously, or from local Git, etc. You can see more at the left sidebar of these pages.
For deploying Node.js app on Azure Web App for Containers, it's a simple way to deploy the app on Azure as similiar as on local docker.
Create a Node.js web app in Azure App Service on Linux
Build a Node.js and MongoDB web app in Azure App Service on Linux
To deploy via FTP, cloud sync, or deploy continuously, or from local git, etc. Also, you can see more at the left sidebar of these pages.
Some important tools will help deploying easier.
Deploy via VSCode, you can refer to these offical documents for WebApp(App Services) or Container(Docker Images).
To deploy on WebApp not Container, Kudu is a common tool for debuging and deployment. Meanwhile, for Node.js app, we need to use iisnode to connect IIS as revese proxy for your app, and configure the web.config file via follow the kudu wiki document. The Kudu wiki is very useful and valuable for new to Azure.
There are more details for this topic which can not be listed one by one at here, but the above these are necessary. The offical guide for Javascript developers is helpful for new to Azure.
Jay Gong posted a great answer for hosting on Azure. However, you might want to ask your client if s/he means s/he wants a micro services architecture. For more information on micro services, check out this link.
The other viable option would be an App Service (which is an Azure service that manages deployment and abstracts a lot away, but there's a VM under the hood)? Without a VM for hosting, it would be rather difficult to do anything in the cloud on Azure - the only other option is local hosting, which would be without Azure. I would argue that it ruins the purpose of using cloud services, as it seems your client is confused.

Setting node.js site to auto-start when hosted in Azure Web app

I have a Node.js script that I want to run in Azure on a Web app.
This script is not an express web site, rather it's a worker script which polls a database for work to perform, and when done it just polls and waits, e.g. there is not user interface for it.
I notice that after deploying it, even though it's setup with iisnode, it won't actually start until I fire up a browser and navigate to the Azure Web app host, even though it doesn't have a UI.
Only when I navigate to it does iisnode start logging and fire up my application. Then it happily polls the database and performs the required work.
Does anyone know how you can make a site just automatically start when deployed?
There seem to be autostart web.config settings available with IIS, but I don't know how to get iisnode or the Azure Web app to support it.
I could set up a Web job on the machine that just performs a GET from the site, but that seems a bit of overkill and messy.
You can leverage Function App to satisfy your requirement. Also, your original solution which build an Azure Web App without UI should be work.
However, please pay attention that Azure App Services will be unloaded after they have been idle. You can enable the Always on application setting to keep the app loaded all the time. Please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/#application-settings for more details.
Any further concern, please feel free to let me know.

How do I update the version of iisnode on a Windows Azure Cloud Service image

I had a working Windows Azure Web Site running my node.js app and everything was working fine. I ended up needing to run a native node.js module (fibers), which necessitated that I move to a Windows Azure Cloud Service. I used the Convert to Azure Cloud Service wizard, which created a web role that allowed me to deploy my app as a cloud service and run fibers under node. So far so good.
My app requires WebSockets, which are supported under Azure Web Sites (more or less automagically when you turn it on from the config UX). I've been fighting to get WebSockets working with the Cloud Service for a few days now, and I have determined that my problem is that the version of iisnode that runs by default in a Cloud Service is too old to support node.js WebSockets in the normal way. The Cloud Service installs iisnode version 1.21 and the WebSockets support in iisnode didn't show up until version 2.0 (I have no idea why the Cloud Service image uses that crusty old version of iisnode).
Note that I don't want to use a worker role and listen on a different port (which I gather is how a lot of people address this).
Unfortunately, I cannot figure out how to install a more up to date version of iisnode in my Cloud Service (I gather that it's possible to run an installer at the startup of the Cloud Service (possibly via setup_web.cmd), but that's as far as I've gotten.
Any pointers on what I need to do to get my Azure Cloud Service running a newer version of iisnode?
To update the version of iisnode installed on Azure Hosted Service you need to:
Download the newest x64 installer for iisnode from http://go.microsoft.com/?linkid=9784331
Include that *.msi file in the package you are deploying to the Hosted Service.
In your setup_web.cmd, install the new iisnode with msiexec /i iisnode-full-iis7-v0.2.7-x64.msi /passive. This must be run as admin, but then I believe setup_web.cmd already runs as admin.
Alternativelty, for a one-off installation, you can just TS to the machine and install it manually.
By the way, what is preventing you from using the native module in Windows Azure Web Sites?

Resources