trevor-laher / OnDemandMinecraft

An AWS hosted Minecraft server that will only run when players are active. Players can start the server through a simple UI accessed through free Heroku server hosting.
MIT License
517 stars 68 forks source link

Instance not stopping #13

Closed BNZ78 closed 5 years ago

BNZ78 commented 5 years ago

autoshutdown.sh is not stopping my aws instance. Any ideas about how can i troubleshoot this problem?

trevor-laher commented 5 years ago

Definitely try to find the logs somewhere. Make sure you follow every step of the readme as well. Do you have the script running on the CRON scheduler? The script will work if it has sudo permissions, is running on the scheduler, and the screens directory is properly configured. If the screen directory isn't properly configured, autoshutdown.sh won't be able to access the server console through the screen as AWS will otherwise delete the screen temporary files.

BNZ78 commented 5 years ago

Definitely try to find the logs somewhere. Make sure you follow every step of the readme as well. Do you have the script running on the CRON scheduler? The script will work if it has sudo permissions, is running on the scheduler, and the screens directory is properly configured. If the screen directory isn't properly configured, autoshutdown.sh won't be able to access the server console through the screen as AWS will otherwise delete the screen temporary files.

I'll check the logs. Congratulations on this project, it's very useful.

ainskeep commented 5 years ago

I've been having some trouble with the auto shutdown too. Cron is working, but when it runs I get this output:

ubuntu@host:~$ sudo ./autoshutdown.sh ./autoshutdown.sh: 5: ./autoshutdown.sh: You: not found ./autoshutdown.sh: 7: ./autoshutdown.sh: You: not found PLAYER left the game

RogueToad commented 5 years ago

I've been having some trouble with the auto shutdown too. Cron is working, but when it runs I get this output:

ubuntu@host:~$ sudo ./autoshutdown.sh ./autoshutdown.sh: 5: ./autoshutdown.sh: You: not found ./autoshutdown.sh: 7: ./autoshutdown.sh: You: not found PLAYER left the game

I have an entirely identical problem. I've checked the crontab too by adding a logging cron job and it works fine. It appears to be an issue with the screen commands, judging by the line numbers in the output.

trevor-laher commented 5 years ago

Yes, this screen issue might be because the screen temporary directory is getting deleted while the server is running. I had a similar problem when I was first developing this. Make sure that your SCREENDIR environment variable is pointing to a place in your current user directory. This way, AWS EC2 processes won't wipe the active screens. Hope this helps, you may have already followed this step in the readme though.

jaredswarts55 commented 5 years ago

I think this has something to do with the server running as the ubuntu user, but the 'list' commands running from the root user. I think with the current directions the root user isn't using that screens directory and doesn't have access to send commands to that socket. @trevor-laher if you have this running still can you confirm your crontab is running under the root user? if so, is your screens directory owned by the root user instead of the ubuntu user?

trevor-laher commented 5 years ago

With my configuration (which I'm 99% sure is bug free), the CRON job is running under the ubuntu user. I believe the screens directory is owned by the ubuntu user also. My screens directory is located in the ubuntu user's directory also. The "list" command is running inside the minecraft server console so I don't think the user running this command has any impact, I could be wrong.

EDIT: Can anyone test and see if removing "sudo" from AWS Instance Configuration Step #9 would fix this?

EDIT #2: I believe I've actually figured it out, I have crontabs for the same script running under both sudo and ubuntu, I'll see which one is working for my configuration and update the readme accordingly.

trevor-laher commented 5 years ago

SOLUTION: So it appears that the script which actually does complete successfully is being run through the Ubuntu user. The fix to this issue, assuming the screens directory is in ubuntu user and everything else is consistent with the readme is as follows: sudo crontab /home/ubuntu/crontab -u ubuntu or whatever user you are on.