Sunday, September 14, 2014

Minecraft server upstart script

I see a lot of people running minecraft server in strange ways: nohup, bg & disown, tmux, screen, etc. The problem with those options is that they are all ephemeral. If you restart your server you'll need to do it all over again.

Here's a simple upstart script that starts and watches your minecraft server. It runs as a service and works for centos 6.5+ and ubuntu 12.04+

Once you create the file at /etc/init/minecraft.conf, simply run:

initctl reload-configuration
service minecraft <start|stop|status>

upstart script:
# Minecraft upstart script

start on (local-filesystems and net-device-up IFACE!=lo)
stop on [!12345]

respawn

chdir SOME_MINECRAFT_DIRECTORY

exec java -Xmx1024M -Xms1024M -jar minecraft_server.1.8.jar nogui

Logs for the server will be rotated by the server and are available at /var/log/upstart/minecraft.log

3 comments:

  1. Thanks for sharing this article and make me aware about the problem running with minecraft server hosting, but we provide a batter hosting services try Cloudfrost Hosting.

    ReplyDelete
  2. Hey Stephen Wood, thanks! I've been looking for a clean way to start this automatically on my VM.

    ReplyDelete
  3. Thanks for sharing the post. It is really helpful for me. I was facing the issues at Minecraft Hosting but now it's resolved.

    ReplyDelete