![]() Here is some code which interacts with EC2: fn start_instance(ec2: &Ec2Client, t_rt: &mut Runtime) -> Result ", e)) With rust, I used the AWS SDK called rusoto. That playground web application is where I decided to add this functionality. The grandest example is my woodworking portfolio. I have a web application repository called 'playground' which holds some random side projects. I thought it'd be really cool to make a web app that my friends can use to start and stop the server. This is not great for the obvious reason that my time and availability is required no matter who wants to play. The initial/simplest way is by starting the server through the AWS portal when someone wants to play. Turning the server onĪnother problem is getting the server to turn on. ![]() restart unless-stopped is great for keeping minecraft going through server stops & starts. My command to start the docker container isĭocker run -d -e EULA=TRUE -p 25565:25565 -name mc -v /home/freied/minecraft/data:/data -restart unless-stopped itzg/minecraft-serverĪlso pretty easy. Wait 10 min then see if the server is empty. If docker exec mc rcon-cli list | grep "$PLAYERS_EMPTY_MESSAGE" > /dev/null thenĮcho "After waiting 10 min, still no players, shutting down"īasically it has a bunch of short-circuiting if statements. If ! docker exec mc rcon-cli list | grep "$PLAYERS_EMPTY_MESSAGE" > /dev/null thenĮcho "No players online, waiting 10 min to check again" If ! ps ax | grep -v grep | grep $COMMAND_NAME > /dev/null thenĮcho "Minecraft not running, exiting script" ![]() PLAYERS_EMPTY_MESSAGE="There are 0 of a max of 20 players online:" Next, I referenced this script to write a script which would check for player count and shutdown the server if it's been empty for X minutes. This was pretty straight forward with some Docker experience. I started by just getting an EC2 instance on AWS to host a minecraft server through Docker. Why not try to make a dedicated server which only runs when people want it to? EC2 server and auto-shutdown And joining a local session can be tricky with routers, ISPs, firewalls, and VPNs. It's not often, so paying for a full time dedicated server doesn't make sense. Every once in a while my gaming group decides they want to sit back, relax, and chill on a little Minecraft. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |