I have a cloud hosted VPS and set up minecraft on it for my son. I have other apps running on the machine and have used PM2 to 'fix' those apps to restart on reboots/crashes/etc.
I created a script to start minecraft (startmine.sh) containing the following lines:
I then set this with PM2 (pm2 start startmine.sh) and then a 'pm2 save' command
It seems to work fine. Unfortunately, if I log into the machine, the screen session is unavailable. PM2 tells me the script is running and players can log into the game. Unfortunately, it makes it difficult to make changes to the game (such as adding an admin) since the session appears unreachable.
Is there a 'clean' way to start the game on reboots and still allow access when I ssh into the machine? I'd like to avoid installing any additional utilities (hopefully screen and PM2 are enough).
but I'm not sure if that will put all the world files in the right place if I don't cd into the minecraft directory first. I also don't know how I'd reach the minecraft cli if I ssh in (same problem as I have now)
I'm also not sure if just calling the script file from rc.local would do the trick.
I have a cloud hosted VPS and set up minecraft on it for my son. I have other apps running on the machine and have used PM2 to 'fix' those apps to restart on reboots/crashes/etc.
I created a script to start minecraft (startmine.sh) containing the following lines:
screen -S "Minecraft"
cd /minecraft
java -Xmx1024M -Xms1024M -jar server.jar nogui
I then set this with PM2 (pm2 start startmine.sh) and then a 'pm2 save' command
It seems to work fine. Unfortunately, if I log into the machine, the screen session is unavailable. PM2 tells me the script is running and players can log into the game. Unfortunately, it makes it difficult to make changes to the game (such as adding an admin) since the session appears unreachable.
Is there a 'clean' way to start the game on reboots and still allow access when I ssh into the machine? I'd like to avoid installing any additional utilities (hopefully screen and PM2 are enough).
I was thinking a startup of:
pm2 start "java -Xmx1024M -Xms1024M -jar /minecraft/server.jar nogui"
but I'm not sure if that will put all the world files in the right place if I don't cd into the minecraft directory first. I also don't know how I'd reach the minecraft cli if I ssh in (same problem as I have now)
I'm also not sure if just calling the script file from rc.local would do the trick.
Thoughts?
Andrew