Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can I keep my GCP web server keep running?

On a VM instance of Compute Engine, I created a little web server with express js. 

I connected the server to my own domain, xxxx.kr. It works well when I run 'sudo node app.js' . But I quit the cloud shell window, showing "listening 80 port.....". It doesn't work. 

I tried to use pm2 , and some kind of  tools for  automatic server , but all things dont work.

 

My question is:

1. Is it possible to keep running my server after close GCP's  cloud shell? 

2. In real Industry using Google Cloud,  How keep server working without turn on the sessions? 

 

sorry for my poor English..

1 2 119
2 REPLIES 2

You can SSH into your Compute Engine instance and run your Node.js application as a background process to keep it running even after you disconnect.

To achieve this, you can use utilities like pm2 or nohup:

  • PM2: A process manager that ensures your application runs persistently.
  • Nohup: A simple way to run a process in the background.

These methods are commonly used to keep applications running in production environments. Let me know if you need further guidance on setting them up!

Thanks 
Vinoth_GCP