1. When making a thread, please tag your thread accordingly using the menu to the left of the textfield where you name your thread where applicable. Server Advertisements and Mod Releases should be contained to their respective subforums.

Server Discussion Setting up an Ubuntu 12.04 server

Discussion in 'Multiplayer' started by DeMossiah, Dec 5, 2013.

  1. Bradlfett

    Bradlfett Orbital Explorer

    cavelurker likes this.
  2. Bradlfett

    Bradlfett Orbital Explorer

    nano is just a text editor, you can use anyone you like to create the file.
     
  3. SavageCore

    SavageCore Void-Bound Voyager

    Added
    Code:
    validate
    to init.d script.

    Code:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:        starbound
    # Required-Start:    networking
    # Default-Start:    2 3 4 5
    # Default-Stop:        S 0 1 6
    # Short-Description:    Starbound Server Daemon
    # Description:        Starts/Stops/Restarts the Starbound Server Daemon
    ### END INIT INFO
    
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="Starbound Server Daemon"
    NAME=starbound
    DIR=/home/steam/Steam/SteamApps/common/Starbound/linux64
    DAEMON=$DIR/starbound_server
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    
    USER=steam
    GROUP=steam
    DAEMON_ARGS=""
    
    STEAM_DIR=/opt/steam
    STEAM_DAEMON=$STEAM_DIR/steamcmd.sh
    
    STEAM_USER=derp
    STEAM_PASS=derp
    STEAM_APP=211820
    
    [ -x "$DAEMON" ] || exit 0
    
    . /lib/init/vars.sh
    . /lib/lsb/init-functions
    
    do_start() {
        if [ -e $PIDFILE ]; then
            PID=`cat $PIDFILE`
    
            if ( ps -p $PID > /dev/null ); then
                log_failure_msg "$DESC '$NAME' is already running."
                return 1
            else
                rm -f $PIDFILE
    
                start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON --test > /dev/null || return 1
                start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2
            fi
        else
            start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON --test > /dev/null || return 1
            start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2
        fi
    }
    
    do_stop() {
        if [ -e $PIDFILE ]; then
            PID=`cat $PIDFILE`
    
            if ( ps -p $PID > /dev/null ); then
                start-stop-daemon --stop --signal 2 --quiet --pidfile $PIDFILE
                [ "$?" = 2 ] && return 2
            else
                log_failure_msg "$DESC '$NAME' is not running."
                rm -f $PIDFILE
                return 1
            fi
        else
            log_failure_msg "$DESC '$NAME' is not running."
            return 1
        fi
    }
    
    case "$1" in
        start)
            log_daemon_msg "Starting $DESC..." "$NAME"
            do_start
    
            case "$?" in
                0|1) log_end_msg 0 ;;
                1) log_end_msg 1 ;;
            esac
        ;;
        stop)
            log_daemon_msg "Stopping $DESC..." "$NAME"
            do_stop
    
            case "$?" in
                0|1) log_end_msg 0 ;;
                2) log_end_msg 1 ;;
            esac
        ;;
        restart)
            log_daemon_msg "Restarting $DESC..." "$NAME"
            do_stop
    
            case "$?" in
                0|1)
                    do_start
    
                    case "$?" in
                        0) log_end_msg 0 ;;
                        *) log_end_msg 1 ;;
                    esac
                ;;
                *)
                    log_end_msg 1
                ;;
            esac
        ;;
        status)
            if [ -e $PIDFILE ]; then
                PID=`cat $PIDFILE`
    
                if ( ps -p $PID > /dev/null ); then
                    log_success_msg "$DESC '$NAME' is running (pid $PID)."
                    exit 0
                else
                    log_failure_msg "$DESC '$NAME' is not running."
                    rm -f $PIDFILE
                    exit 1
                fi
            else
                log_failure_msg "$DESC '$NAME' is not running."
                exit 1
            fi
        ;;
        update)
            su - $USER -c "$STEAM_DAEMON +login $STEAM_USER $STEAM_PASS +app_update $STEAM_APP +quit"
            ;;
        validate)
            su - $USER -c "$STEAM_DAEMON +login $STEAM_USER $STEAM_PASS +app_update $STEAM_APP validate +quit"
            ;;
        *)
            log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|status|update|validate}"
            exit 0
        ;;
    esac
     
    Last edited: Dec 8, 2013
  4. EinSof

    EinSof Void-Bound Voyager

    You are displaying your steam username and password in the code !!!
     
  5. SavageCore

    SavageCore Void-Bound Voyager

    woops, thanks! Long day...

    Thankfully I have steam guard on lol
     
  6. Joshadow

    Joshadow Void-Bound Voyager

    Hmm, I think I've done everything correctly, never got an error.
    Unfortunately I can't seem to connect to it yet though.


    I run:

    Code:
    root@vps:~# service starbound start
    * Starting Starbound Server Daemon... starbound                                                                    [ OK ] 
    However when I then try to shut it off:
    Code:
    root@vps:~# service starbound stop
    * Stopping Starbound Server Daemon... starbound
    * Starbound Server Daemon 'starbound' is not running.
                                                                                                                                                                 [ OK ]
    Is that the correct way for me to shut down the server? Was it even running in the first place?

    I'm used to using screen on CentOS, I don't know how to switch to the server instance to give it commands if it's a service.

    Some more tips in the Opening Post on how to administrate the server properly might be nice. I can see in the service code that there might be other commands, but you haven't explained how to use them :)
     
  7. cavelurker

    cavelurker Space Spelunker

    Yes, you tried to shut it down the correct way but apparently it wasn't even running. If you want to know if the server has started, you could either use htop (easy GUI cmd-line tool) och run the "status" command aviable in this init file. Also the starbound server can't read in any commands yet, either, so you can't controll it in any way except start/stop.

    Are you currently running CentOS on your server?
     
  8. InterSlayer

    InterSlayer Void-Bound Voyager

    If my server crashes, it doesn't automatically restart.

    Is the init.d script suppose to take care of that or is a separate script needed?
     
  9. cavelurker

    cavelurker Space Spelunker

    No, what I know the server will not be restarted if it crashes, if you use this init script. But I've written another script, that will try to restart, found here: https://github.com/lmas/starbound_server/blob/master/start_server.sh

    Edit: Also note, my script is just an ugly hack compared to the init script, which runs the server in a more "official" way.
     
  10. helio

    helio Orbital Explorer

    I think if you guys use Supervisor, you'll avoid all of the troubles of having to use a init script. https://www.digitalocean.com/commun...nd-manage-supervisor-on-ubuntu-and-debian-vps

    It's just a few lines of code to get it up and running and the script for Supervisor is much less complicated:

    Code:
    [program:starbound]
    command=/path/to/starbound_server
    autostart=true
    autorestart=true
    stderr_logfile=/var/log/starbound.err.log
    stdout_logfile=/var/log/starbound.out.log
     
  11. cavelurker

    cavelurker Space Spelunker

    Wow that is beautiful! I'll have to investigate Supervisor.. But on the other hand it won't filter the server's spammy output.

    Edit: I'll have to split my script and make a separate one just to wrap the server and filter the output.
     
    Last edited: Dec 8, 2013
  12. Joshadow

    Joshadow Void-Bound Voyager

    Nope, since the tutorial calls for Ubuntu 12.04 that's what I'm using. This is on a VPS so I only have the option to SSH, no GUI.

    Any idea why it might not be started?
     
  13. cavelurker

    cavelurker Space Spelunker

    I have no idea, you need to provide more information. It would be good if you could post the server's log output. Have you tried to manually start the server (ie, run: starbound/linux64/launch_starbound_server.sh) ? Unfortunately the init script doesn't save any logs.
     
  14. Joshadow

    Joshadow Void-Bound Voyager

    When running the launch script I get the standard initialization output which ends in the following:

    Code:
    ...
    Warn: Slow asset 0.065 : /dungeons/avian/aviantomb/aviantomb.dungeon
    Info: Done loading Star::Root.
    Info: Server version 'Beta v. Irritated Koala' '616' '418'
    Info: Scanning for router for portforwarding
    Info: Done scanning for router for portforwarding
    Info: Creating world alpha:63183977:11165080:-1088849:7:9
    Killed
     
    GennyP likes this.
  15. cavelurker

    cavelurker Space Spelunker

    The hell? Never seen that "Killed" row before in the server log. Something must be killing the server when it tries to start. I'm not sure what you are running on, do you have enough RAM/CPU power to run the server?
     
  16. Joshadow

    Joshadow Void-Bound Voyager

    Hmm, How much Ram CPU should I have? What are the requirements?
     
  17. cavelurker

    cavelurker Space Spelunker

    I'm running with 2GB RAM and 2.6GHz CPU for a couple of friends only and that's barely enough.
     
  18. Joshadow

    Joshadow Void-Bound Voyager

    Ahaha, ok, my VPS has 128MB :D that might be why. I'll see if I can't set up a more beefy one.
     
  19. cavelurker

    cavelurker Space Spelunker

    Umm yes, a way beefier server is needed for starbound I'm afraid :p The devteam haven't done any memory optimizations yet so it's a beast to run.
     
  20. InterSlayer

    InterSlayer Void-Bound Voyager

    Will check out Supervisor for autorestart and stuff, thanks.

    I run my server at Ramnode on a 1gb memory Ubuntu VPS, 3.4ghz Quad core. Can do about 3-4 players just fine so far. There is occasional server lag, but it's pretty infrequent.
     

Share This Page