Rate my server host gameplan - AWS/TMUX/Bash scripting insights would be wonderful
Alright, so it's time for me and my friends to play our annual 2 weeks of Minecraft. I've got a server hosted on AWS as I have a bunch of credits on there, so it'll be free. I understand using a dedicated host would be better, but I'm doing this as a learning exercise too.
My server is currently hosted on an AWS EC2, with a launch script configured to run the server whenever I boot the EC2. It works great and I can connect to it.
I've also written a react webpage dashboard that uses APIgateway + lambda to ping the EC2, and report whether the server is online. If is it not, it also allows the EC2 to be launched from a button on the dashboard. All this is working and hosted online.
My next goal is to have the dashboard show the count and names of active players online so people can see who's on. Also, once I have this info I'll write a script that stops the server when no one has been on for an hour to save $$. The output of the /list command would be perfect for this, and I just need access to that data somehow.
I'd ideally like another lambda function to be able to connect to the server, execute the /list command on the currently running server, and return the output.
This is where I hit a wall. As the server is being run by the automated startup script, I don't know how to access that terminal/process to execute the /list command.
I have been reading about TMUX, and this seems like it could be a viable solution. I'd configure the startup script to launch the server using TMUX, and then I'll be able to talk to that service when I reconnect to my ec2.
Before I dive into learning TMUX and writing all these scripts, if anyone could suggest any improvements to this process that would be fantastic, as I don't have a heap of experience in this area.
Thanks for reading! Any help is greatly appreciated 🙂
9 Replies
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close
!close
!solved
!answered
Requested by sloper64#0
EC2 is already a big no
if you ever get just SLIGHTLY popular, you will be paying 100 usd a month on just 15-20 players average
EC2 in itself is also just pretty damn expensive, also would highly recommend just using docker, due to the isolation factor etc
Not advanced in this at all, but to return player count and names couldn’t you just use ping/query? https://mcsrvstat.us
Yeah that's fair. It's just that I have $300 of credit that expires in November, so I'm happy to churn through that. I have had issues with CPU credits running out which hasn't been fun.
I'll look into Dockerising it though!
You absolute hero. I didn't know that existed, and it also has an API! This just completely solves my issue, much obliged!
you're welcome! Hopefully it resolves your issue.
side note, make sure to enable query for playerlist over 12, i think?
>8 iirc
Without query, it's a 8 player random sample out of all players on the server
People can also opt out of being returned from query player list with a recently added setting iirc, so query does have that downside.
yeah, thanks for correcting me
Update, I've got it completely working now. The server now automatically shuts down after an hour of being online with no players, using the api you linked. Thanks again for that!
You’re welcome! Hope all goes well with your server.