Reputation: 183
I recently tried out Google Cloud for running node.js applications. Currently, I have a node Minecraft bot (using the library Mineflayer) running on a VM instance in the compute engine at Google Cloud.
The problem I encountered was that when there is no active SSH connection from my pc to the VM, the MC bot leaves the game. When there are players online, and I close the connection to the VM, the bot leaves after a few minutes.
Is this a setting in the compute engine that I need to turn on, to keep scripts running, or could there be something else? I am new to Google Cloud, and also pretty new to node.js, so if anyone has suggestions or fixes I would really appreciate a comment.
Upvotes: 0
Views: 812
Reputation: 11
To get around this use screen
.
Using screen
you can create multiple virtual terminals which will remain alive even after the SSH session ends.
To install screen
use:
sudo apt install screen
To start your server:
sudo screen -S <SESSION_NAME> node server.js
SESSION_NAME
would be the name of your virtual terminal.
To exit the new virtual terminal press CTRL+A and CTRL+D in quick succession.
To access your terminal use:
sudo screen -r <SESSION_NAME>
Upvotes: 1