Search code examples
google-cloud-platformdeploymentweb-deployment

Google Compute Engine goes to sleep after some time


I'm trying to run my application on GCE VM. It uses nodeJs as frontend and a Java backend. I use this server to communicate with my local computer using MQTT.
This is working but after some time (one hour and a half), the server seems to go to sleep (or the ports close ?). Both MQTT and ssh terminal interface connections are lost.

When I connect back, the application is not running anymore, it seems like the VM restarted.

Do you have any idea on how to keep my server alive ? I can give further details.


Solution

  • Answering my own question as John Hanley explained the solution in comments:
    "By what method are you running your frontend and backend code. VMs do not go to sleep. If you are starting your software via an SSH session, that will be an issue. Your code needs to run as a service. Edit your question with more details."

    I was indeed running my application via the ssh terminal which caused the problem. The solution for me was to remotely access the VM via vncserver and to launch the application using the VM's terminal.