Host your own StarMade server on the cheap

So it looks like our StarMade server isn’t quite handling itself in the most graceful way. While this is looked into I thought I’d give a quick how-to on how to run your own server at minimal costs (Note this is based on a new plan, rather than the current plan that’s failing!). There is a bit here that’s a bit technical but bear with me. Please feel free to leave a comment if you need any clarification, I’ll reply as soon as possible.

To follow along with the guide exactly, I used a 1G droplet at USD $10 a month. You can get away with the 512M droplet but you wont get many users on it, good enough for small private servers though.

Obtain and start up a server

Firstly you need some hosting with shell access. In my personal opinion the best bang for your buck is with DigitalOcean so this guide will also give instructions for setting up a ‘droplet’ there first.¬†Once you’re signed up, and logged in you need to click ‘Create’ or ‘Create droplet’

  • Firstly enter a hostname. This is just the name that you’ll know the server as. I went with ‘starmadetest’ in this tutorial
  • Select your size. If it’s for just yourself and a couple of friends you can probably get away with the 512M. For a rough estimate on which is best for you see the image below.
  • They have regions in New York (West coast USA), San Fransisco (East coast USA), Amsterdam (Europe). Select the one closest to you for best results.
  • If you’ve got a preference in OS pick one here, this guide will continue primarily with CentOS but also Ubuntu/Debian commands where appropriate. Pick the latest x64 version of your choice
  • Ignore the SSH key bit for now, definitely look into it if you’re interested in learning the ins and outs of a server but we’ll go password-based for now.
  • Keep VirtIO enabled
  • Click create droplet and wait for it to be set up. When it’s complete, you should have the password in your email account.
do-starmade-slots
Click to enlarge

Once that stage is done and you have your password to hand, we’ll grab a piece of software named PuTTY, which allows you to log into Linux servers via SSH. You’ll need to grab putty.exe and run it. You’ll get a window like this:

In the host field type [email protected], where ipaddress is the IP of your droplet. Click Open.

putty-login

After this step you may get a window such as this. Press Yes

putty-secalert

You should then get a login prompt for your server, in this type in your password. Note that this needs to be typed in exactly (Including any capital letters), but also note that it will not display the password as you’re typing, this is normal! Once you’ve typed it in, hit return again. You could optionally paste the password from your email. To paste, right click inside the PuTTY terminal window. Again the password will not display. Hit return after you right click.

If all goes well, you’ll be here:

putty-loggedin

Firstly we’ll give the OS an update, being an image it might be slightly behind. Type in (or again, copy and right click to paste) yum -y update and hit return. Once that finishes scrolling and you’re back to the prompt ( [[email protected] ~]# ) your droplet is up to date. If at any point the yum command asks “Is this ok? [y/N]” type ‘y’ and hit return.

We need to install the java openjdk and a tool named ‘screen’ for StarMade to run. An easy(ish) to use text editor is nano, so we’ll install that here too. This can be done with
yum -y install java-1.7.0-openjdk screen nano

Allow StarMade through the firewall with the commands
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 4242 -j ACCEPT
iptables -A INPUT -i eth0 -p udp -m udp --dport 4242 -j ACCEPT
service iptables save

Next we’ll add a standard user account (Don’t run your game servers as root!) useradd starmade and set its password passwd starmade
Set a password you’ll remember, as you’ll need it shortly and again if you ever need to restart the game server. Again it wont display the characters as you’re typing, this is normal. On completion the terminal should say “passwd: all authentication tokens updated successfully.”

Next type in the command ssh [email protected] and hit return. Enter the password you set just now. This will log you into the starmade account (Linuxy types will know you can use su, but screen doesn’t like it off-the-bat and I want to keep this easy to follow!)
If it says “Are you sure you want to continue connecting (yes/no)?” type ‘yes’ and hit return.

You should now be here:
putty-starmade-login

Install StarMade

Type or copy&paste the command wget http://files.star-made.org/StarMade-Starter.jar This will download the Linux version of StarMade.

Lets install the server with the command java -jar StarMade-Starter.jar -nogui a bunch of text should scroll by, once complete StarMade has been installed in the ./StarMade directory. Just to note, to update the server later shut it down and run the install command again, it’ll automatically update everything.

putty-starmade-installed

Lets add ourselves as an admin (If you don’t do this everyone will be an admin!)

nano -w StarMade/admins.txt and add your username (and friends if required, put them one per line).

starmade-admin

Save the changes with Ctrl+O, Enter and exit the file with Ctrl+X

Now we’ll create our starter script. Firstly we need to know how much RAM we’re going to give the server. Take the amount of RAM you’re renting from DigitalOcean. For a quick estimate run the following command (It takes our current memory and converts it from Bytes to Megabytes then subtracts 128M for the OS’ usage)

echo;echo $(( `grep MemTotal /proc/meminfo | awk '{print $2}'` /1024 - 128 ))

putty-memoryestimator

Remember the number (In our example, 868) for a moment.

Change directory to StarMade cd StarMade and run the command nano -w start.sh and paste the following text into the window that opens, changing 868 to the number you got.

#!/bin/bash

cd "$(dirname "$0")"

screen -S starmade java -Xms256m -Xmx868m -jar StarMade.jar -server

putty-editfile

To write the file and exit, press Ctrl+O and hit enter. Then press Ctrl+X and you should be back to the terminal window.

Run the command chmod +x start.sh to turn your script into an executable file.

To finally start the server, use the command ./start.sh

Another bunch of text should roll by, when it stops scrolling your server should be up! Connect to your server using the IP address from earlier on port 4242. For example mine in this tutorial would be 82.196.2.246:4242

starmade-starter

You can safely close the terminal window now, or to just exit from the server window back to the terminal press Ctrl+A then d

Restarting the server and server updates

Generally speaking if you can, use the /shutdown command in StarMade itself to shut the server down nicely.

Now that you have the starmade user, you can just log in using that – i.e. in the PuTTY hostname use [email protected] instead of [email protected]

To see what the server’s currently doing run the command screen -x starmade

starmade-user-screen

To exit from that window use Ctrl+A then d

If the server has completely hung and isn’t responsive to anything you can force it to shut down with the commmand
killall -9 java. This isn’t recommended as general usage but if needs must it seems to be the only way to stop the server..

To start the server again go into the directory StarMade once more cd StarMade and run the command ./start.sh as before.

To update the server make sure the server is shut down and go back to the home directory cd and run the install command again. java -jar StarMade-Starter.jar -nogui then when the text has finished scrolling by start up the server again


Cohan

Techie. Nerdy. That guy. Check out the nerd streams on Thursdays for more! I also have a personal website over at Cohan Robinson

2 thoughts on “Host your own StarMade server on the cheap

  • 9th July 2013 at 3:29 pm
    Permalink

    Nice simple instructions, good read

    I did things the awkward way Hah!
    2-users(in a group) a starmade folder (owned by that group) with r-w-x perms
    “i over complicated this”

    Reply
  • 24th July 2015 at 10:43 pm
    Permalink

    Thanks for the simple and perfectly working guide.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *