December 19, 2013 - by Nate Fitch
At a recent Joyent hackathon, I threw out the idea to "nail the Minecraft experience" on Joyent's public cloud. What did that mean? Single command Minecraft server administration with automatic backup and fancy maps! This isn't the first time I've pulled out this type of goofy shenanigans. For example, my high school required the completion of a "senior project" to graduate. While some of my fellow students chose to do their projects on more useful and noble things, I did mine on juggling. Ok, technically the term is "object manipulation" because my project involved more than just throwing balls in the air, but I digress. Same thing with Joyent and Minecrab. While others threw out ideas like mdb support for Go, I suggested what became Minecrab.
Despite my obvious attempt to subvert the hack fest for my own selfish reasons, my colleagues Philip Borenstein, Filip Hajny and Drew Miller joined me for a couple fun-filled days of hacking together a set of tools that can:
The result is on GitHub at joyent/minecrab, which is entirely open source. Contributions to the code are welcome and encouraged!
So how do you use it? First, a disclaimer that the command line tools have only been tested from Mac OS X and Ubuntu, though we'll gladly accept patches for other *nix variants. If you already have the CLI tools from Joyent installed, you're already most of the way there. Otherwise, the easiest way is to follow our Minecrab README that points to links on installing the necessary software (node, npm, manta tools, sdc tools, the jsontool and Minecrab), generating an SSH key, signing up for a Joyent account, and setting up environment variables.
The tedious part over with, now you can test if things are working by attempting to list your minecrab servers:
$ minecrab-list No servers found running or backed up. Launch a new server using the minecrab-launch command!
Then launch a server with a name:
$ minecrab-launch frist Launching frist....................... Done! Server frist running on 220.127.116.11 id: 067494d4-987b-477f-c086-9d9187a52808 Setting up... [some stuff redacted] Connect to server at 18.104.22.168! Status Website: https://us-east.manta.joyent.com/Joyent_Dev/public/minecrab/index.html
There are a few things this did:
The status page is meant to be the place where you can point people to discover what server to join and get the lay of the land (if you've generated a map from your world). Or pull up the map to show off your world to family and friends!
Back to the command line, you can also get status there:
$ minecrab-list IP STATE NAME 22.214.171.124 running frist
When you try to connect with your Minecraft client, you'll probably get a message stating "You are not white-listed on this server!", so go ahead and whitelist yourself:
$ ./bin/minecrab-add-friend frist [your minecraft name] Finding server... Done!
You can see who you have whitelisted at any time (whether your minecrab world is running or not) with the
minecrab-list-friends [server name] command. So, if you want your friends to come play, simply add them with the add-friends command, just like you did for your own name.
Now when you're done playing, shut down your server:
$ minecrab-shutdown frist Finding server... Found frist (126.96.36.199)! Are you sure you want to shut down frist? y Saving the world... [some stuff redacted] Done!
That did a couple things too:
Now when you list you'll see that your world is offline (note that I launched a second world while your attention was elsewhere):
$ minecrab-list IP STATE NAME 188.8.131.52 running sceond n/a offline frist
Finally, when you're ready to play that world again, just launch it by name, like you did originally. Instead of generating a new world it will download the world data that was backed up to Manta and restarts where you left off:
$ minecrab-launch frist
Now that you've had an overview, here are some other helpful commands:
minecrab-get: Get details about the Minecrab server (ip address, hardware configuration, Joyent cloud identifiers, map location, etc).
minecrab-copy: Make a copy of your minecraft world.
minecrab-annihilate: Remove all traces of your Minecraft world (has to be shut down for this to work).
minecrab-console: If you're familiar with the Minecraft server console, this attaches and allows you to interactively issue commands.
minecrab-map: Manually kick off a map job.
minecrab-backup: Manually kick off a world backup.
Naturally with hack fest code there are some things that aren't so great yet. First, the map renders on Manta take a while- about 5 minutes for a new world, and hours for large worlds. We're looking into how to reduce that time, either by parallelizing the render (it is Manta, after all!) or by only regenerating what has changed. Secondly, there's no easy way (yet) to migrate a world onto Minecrab, though it should be fairly straight-forward for those that already administer servers. I migrated two of my single player worlds as proof it can be done and there should be a doc on how I did it soon. You can see all the issues on the minecrab github issues page.
So...did we nail the Minecraft experience on Joyent? If the target audience is the set of people who are comfortable generating SSH keys and use a CLI, then sure! But that's not really the target audience. The eventual target is everyone else. We (Joyent) have some things in the works that will make this experience even better. In the meantime, happy crafting! Oh, and watch out for Herobrine!
<Cue creepy music... and... cut!>