DEV Community

Discussion on: How To Run A Modded Minecraft Server on AWS

andrewbrown profile image
Andrew Brown 🇨🇦

Most servers need to run via sudo to access specific libraries so this is normal.
It could be the case thats where you need to place sudio.

If I didn't have it you don't need it.

You can also just attempt changing the ownership of the eula.txt file because maybe it was created as root user by mistake.

If you are using Amazon Linux then you just need to do chown: ec2-user:ec2-user eula.txt and this may resolve your issue.

Thread Thread
hsimah profile image

I'm at work at the moment so I can't do more testing.

A few things I can note:

  • Running /usr/bin/java ... on its own (no sudo) works fine and I can play on my Minecraft server when it starts up, mods and all.
  • Having the same command execute via system service fails due to permissions.
  • Having the system service run via sudo works, but does not create/read the eula.txt

Permissions on the directory are ec2-user:ec2-user and that user can create, update and delete the eula.txt. I might go through the whole set up and make sure everything is configured correctly on the AWS side, but it seems odd that I can run the server myself, but when I try and set it as a service it fails. Having done Windows services for many years I do know it's usually some sort of permission that is the issue.

On another note - how do you persist your game world? My thought would be to create a cron job to store the world in my S3 periodically.

Thread Thread
andrewbrown profile image
Andrew Brown 🇨🇦

Your EC2 instance has an EBS volume which is your virtual hard drive. You can take snapshots which are then stored on AWS managed S3. When you take additional snapshots it only backs up the difference in changes like a git repository.

They don't recommend to take EBS snapshots while the server is running but you certainly can and this is what I do and I've had no ill adverse effects (data loss or reduced server speed).

You could also sync just the files you want to s3 but this I think is less desirable now that I've done both methods.

You can automate EBS snapshots on schedule via CloudWatch events. CloudWatch events are basically serverless cron jobs, and much better than configuring your instance.