Skip to main content

Starbound Dedicated Server Setup

Setting up persistent Starbound on Debian

Starbound is a Terraria survival/build like game set in space. Based on watching few videos and playing it for a bit I concluded that except for the over abundant life and loot on every planet this game appeals to me very much. And so along with my minecraft.danols.com server I have decided to run a starbound.danols.com 24/7 dedicated one for Starbound; below is how I did it.

Get a dedicated Debian linux server

If you don't have yet a linux server I recommend going with Linode Xen VPS hosting - the basic first package will suffice. I have been with them for over 5 years now and can not say enough good things about them.

Yes, there are chepaer alternatives out there but heed the warning that you get what you pay for. With the basic package I am able to run a Freeswtich VOIP server, Minecraft, email, and few websites. Their setup instructions are solid so use that to provision a Debian 7 instance.

Please use the above link or this 7d884fa5262b62b8735502da003fee34061db49b referral code as I will get a small kick back if you do sign up.

Pick a domain address for your Starbound server

If you don't have a domain provider yet I recommend 1&1 Internet. I have used GoDaddy and 1and1 side-by-side over the last few years and I lean towards 1and1 since their prices are good and you also get private registration for free.

Once you get a domain, edit 1and1 or GoDaddy DNS (Domain Resolution Servers) entries and point them at Linode's servers.

After you get the DNS setup with your domain registrat, log into your Linode account and adjust the DNS entires there to point to your server, this is only needed if you are running the server under a subdomain like myself. Below is a screen shot of my starbound.danols.com settings.

To confirm everything is setup correctly ping your domain and if there is a response you are done with this step. This means that now when players want to join your server they just type your domain address instead of your IP.

root@sh1:/usr/local# ping starbound.danols.com
PING starbound.danols.com (69.164.217.6) 56(84) bytes of data.
64 bytes from sh1.danols.com (69.164.217.6): icmp_seq=1 ttl=64 time=0.051 ms
64 bytes from sh1.danols.com (69.164.217.6): icmp_seq=2 ttl=64 time=0.065 ms
64 bytes from sh1.danols.com (69.164.217.6): icmp_seq=3 ttl=64 time=0.064 ms
--- starbound.danols.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.051/0.060/0.065/0.006 ms

Copy the Linux server binaries from your Steam's Starbound folder

Your windows Steam based installation of Starbound includes Linux execetubales to run a dedicated Starbound server. Using a SFTP WinSCP client copy <install directory>\Steam\SteamApps\common\Starbound\linux64\*.* files to /usr/local/starbound-server/linux64/ and <install directory>\Steam\SteamApps\common\Starbound\assets\*.* files to /usr/local/starbound-server/assets.

The final folder structures looks like this:

/usr/local/starbound-server/
                           /assets/  (files from asssets in steam folder)
                           /linux64/     (files from linux64 steam folder)

If you are curious why are we placing our Starbound server under '/usr/local/' folder structure feel free to read Debian FilesystemHierarchyStandard wiki.

Create a starbound-server user and the system startup script

To SSH remote into your server I use Kitty which is a putty clone with extra handy futures such as the ability to store passwords.

To create a limited starbound user which the server will run under execute adduser command as follows:

root@sh1:/usr/local/starbound-server# adduser --home /usr/local/starbound-server/ --shell /bin/false --no-create-home --ingroup daemon --disabled-password --disabled-login starbound-server
Adding user `starbound-server' ...
Adding new user `starbound-server' (1005) with group `daemon' ...
Not creating home directory `/usr/local/starbound-server/'.
Changing the user information for starbound-server
Enter the new value, or press ENTER for the default
        Full Name []: Starbound Server
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]

Now to create the game server startup init system script execute nano /usr/local/starbound-server/starbound-server-init.d-script.sh and paste the following script contents into it.

#!/bin/sh
### BEGIN INIT INFO
# Provides:      starbound
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:    $local_fs $remote_fs $network $syslog $named
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the starbound server
# Description:      starts starbound using start-stop-daemon
### END INIT INFO

### NOTE: after linking it into init.d run `update-rc.d starbound-server.sh defaults`

### Settings
PID=/var/run/starbound-server.pid
DAEMON=/usr/local/starbound-server/linux64/starbound_server   # Server BIN
DAEMON_FOLDER=/usr/local/starbound-server/linux64/            # Folder where starbound_server file lives
DAEMON_OPTS=""                              
NAME=Starbound                                            # Name of process
DESC="Starbound server"                                   # Desc of process
USER=starbound-server                                     # User used to run the process (do not use root)


# Check if user exists
if ! id -u $USER > /dev/null 2>&1; then
        echo "The user does not exist; execute below commands to crate and try again:"
        echo "  root@sh1:~# adduser --home /usr/local/starbound-server/ --shell /bin/false --no-create-home --ingroup daemon --disabled-password --disabled-login $USER"
        echo "  ..."
        echo "  root@sh1:~# chown starbound-server:daemon /usr/local/starbound-server/ -R"
        exit 1
fi

### Check if server file exists and is executable
if [ ! -e $DAEMON ]; then echo "File $DAEMON does not exist"; exit 1; fi
if [ ! -x $DAEMON ]; then echo "Server file is not executable; run 'chmod +x $DAEMON' to fix."; exit 1; fi

set -e

. /lib/lsb/init-functions


start() {
        # start the server
        # echo "start-stop-daemon --start --make-pidfile --pidfile $PID --chuid $USER --chdir $DAEMON_FOLDER --exec $DAEMON -- $DAEMON_OPTS"
        start-stop-daemon --start --make-pidfile --pidfile $PID --chuid $USER  --chdir $DAEMON_FOLDER  --exec $DAEMON -- $DAEMON_OPTS > /dev/null &
       
}

stop() {
        # gracefully stop the server
        start-stop-daemon --stop --signal INT --pidfile $PID --chuid $USER --oknodo --exec $DAEMON
}

case "$1" in
        start)
                log_daemon_msg "Starting $DESC" "$NAME"
                start
                log_end_msg $?
                ;;

        stop)
                log_daemon_msg "Stopping $DESC" "$NAME"
                stop
                log_end_msg $?
                ;;
        restart)
                log_daemon_msg "Restarting $DESC" "$NAME"
                stop
                sleep 1
                start
                log_end_msg $?
                ;;

        status)
                status_of_proc -p $PID "$DAEMON" starbound
                ;;

        *)
                echo "Usage: $NAME {start|stop|backup|restart|status}" >&2
                exit 1
                ;;
esac

exit 0

error while loading shared libraries: libvorbisfile.so.3: cannot open shared object file: No such file or directory

You might get the above error message so let's run aptitude install libvorbisfile3 which resolved the missing library issue for me.

Final steps and test run

Ensure that all files are owned by the startbound-server user - do this by executing chown starbound-server:daemon /usr/local/starbound-server/ -R. Add the startup script to the boot process by linking it from '/etc/init.d' folder and adding it to the startup sequence as follows:

root@sh1:/usr/local/starbound-server/assets# ln -s /usr/local/starbound-server/starbound-server-init.d-script.sh /etc/init.d/starbound-server.sh
root@sh1:/usr/local/starbound-server/assets# update-rc.d starbound-server.sh defaults

Test the entire setup by starting the game server /etc/init.d/starbound-server.sh start, and logging into your new shiny server. Feel free to follow me on Twitter @danielsokolow and comment if you have any questions.

And lastly do log into my persistent server at starbound.danols.com to check it out.

Troubleshooting

Best way to troubleshoot is to start the server manually and look for any errors in the console, to start the server manually do as follows:

root@sh1:/etc/init.d# cd /usr/local/starbound-server/linux64/
root@sh1:/usr/local/starbound-server/bin# ./starbound_server
Info: Creating Star::Root with 1 assets sources and config file: './starbound.config'
Info: Loading Star::Assets from: '../assets'
Info: Loading Star::Root...
...

Warn: Slow asset 0.081 : /objects/generic/capsulemed/capsulemed.png:default
Warn: Perf: UniverseServer::createWorld millis: 6830
Warn: Perf: WorldServerThread::sync millis: 363
Warn: Perf: UniverseServer::doTriggeredStorage millis: 363
Warn: Perf: UniverseServer::run.innerloop millis: 473
Info: Shutting down world alpha:-61930447:-6722809:-4350314:8:6

Tips

Tailing the log in style

The log is very noisy, but you can mitiage some of that by using a good log coloriser like 'ccze'; to install and use execute the following:

root@sh1:~# aptitude install ccze
...
root@sh1:~# tail -f -n 50 /usr/local/starbound-server/linux64/starbound_server.log | ccze -A
...

Auto re-start the server if it dies

I've noticed the server seems to stops running after a while which - I attribute this to the beta code quality - as a work arround I created the following cron entry which just executes /etc/init.d/starbound-server start; the start-stop-deamon takes care of not spawning a new server if it is already running for us.

I like to be explicit so I anmed the below as /usr/local/starbound-server/starbound-server-cron.d-entry and linked it as /etc/cron.d/starbound-server-start-if-needed. Note that files in cron.d must not have periods in them.

# On Debian system symlink this file into your `/etc/cron.d` folder like so
#
# > ln -s /usr/local/starbound-server/starbound-server-cron.d-entry /etc/cron.d/starbound-server-start-if-needed
#
# Do ensure permissions and ownership are as follows (see http://askubuntu.com/questions/54857/can-symlinks-be-use$
#
#    -rwxr--r--  1 root daemon  215 Dec 12 15:01 starbound-server-cron.d-entry

 */15 * * * * root /etc/init.d/starbound-server start

Comments

  1. Great article! It solved my problem.
    May I translate it into traditional chinese and post to my blog?

    http://essoduke.org/

    ReplyDelete
    Replies
    1. Absolutely - just if possible please link to this post - thanks.

      Delete
  2. Hello Daniel,
    Why do you have to copy assets on the server ?
    This is for the client ? no ? Assets is near 1Go

    ReplyDelete
    Replies
    1. Hello Rafarel, if my memory serves me right when I tried without it it failed to load - please post back here if that is not the case so others can benefit.

      Delete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This has the exact problem as your minecraft startup skript!
    The server gets killed instead of a shutdown. this is suboptimal as the server could be writing the savegame to the disk right when you kill it

    ReplyDelete
    Replies
    1. Mitchell, what do you suggest instead? I agree that server "kill" is more destructive than "shutdown" so how would you change it to make it optimal?

      Delete

Post a Comment

Popular posts from this blog

How to child proof a fireplace

DIY - Do it yourself fireplace child guard Our wonderful 8.5 month old Sofia has become a crawling race car with an untamed thirst for exploration. And so with the cold nights approaching we needed to child proof the fireplace. This however proved to be more difficult than would reasonably expect, I've checked the local Toys "R" Us, Walmart, and even a Canadian Tire with no success for a ready to use product. Internet search was more fruitful and returned a few online stores one could order from, however in all honestly they didn't look too sturdy to me. So I build my own relatively quickly and inexpensively. Materials needed is a privacy plastic lattice - the smallest hole pattern - a few screws and anchors; tools needed are a drill, and a handsaw if you don't have the lattice cut at the store - that’s it. The construction consits of screwing the lattice into the wall and the final product is easiest explained through following pictures. Feel free to +1 this po…

Duplicate value found: duplicates value on record with id: <unknown>.

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>.The above error is triggered in the database layer and caused by a trigger or workflow outside of your main code of block that is bubbling this exception. This is rather difficult to track down especially if you are unfamiliar with the code, I am sharing my procedure in the hopes this saves you time - if you find this helpful drop me a line or follow me on twitter @danielsokolows. This error is caused by unique field constraint on the object, so the first step is to examine the object and locate the API names of all unique fieds. You can do this through SF direclty 'Setup < Customize &lt <object being inserted> &lt Fields' or by downloading the `src/objects` metadata information and searching for <unique>; I preffer the latter and actually download ALL matadata information f…

Storing passwords in PuTTY

How to save SSH username/password for auto login in PuTTy The answer is you can't do it...at least in plain PuTTy. However there is an awesome fork with that let's you store the username and password and other additional features called KiTTy.



So grab yourself a copy and +1 this if you do, thanks.