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.

Tutorial Using Ubuntu Upstart to keep your dedicated server running after crashes and reboots

Discussion in 'Multiplayer' started by 1bitwonder, Dec 8, 2013.

  1. 1bitwonder

    1bitwonder Void-Bound Voyager

    Note this guide is for Ubuntu servers only! Other distros will have other tools that accomplish similar things. I'm not familiar with other distros, sorry!

    So you've got your server installed, and you want to have your server start on boot and come back alive automatically after crashes. Different from the original guide, you won't be needing screen or tmux any more!

    I'm assuming you followed the guide and/or the linux user you're running the server under is named starbound.

    As root (ie using sudo), edit the /etc/init/starbound.conf in the editor of your choice, and paste this upstart script in:

    Code:
    #!upstart
    description "Starbound"
    
    # Start the job
    exec su -l starbound -c '/home/starbound/server/linux32/launch_starbound_server.sh'
    
    # Start on boot
    start on filesystem and net-device-up IFACE=lo
    
    # Restart the process if it dies
    respawn
    
    # Give up if restart occurs 10 times in 90 seconds
    respawn limit 10 90
    Replace the starbound in the 5th line if your user is named differently or your startup script is in a different place.

    After that, give your server a good kickstart by entering this command:

    Code:
    sudo start starbound
    And you should be all set! Your server should start on boot and revive itself after crashes. You can manually stop or restart your server using

    Code:
    sudo stop starbound
    sudo restart starbound
    You can test out what happens during a crash by killing the process too (note the outputs of the first and lastpgreps. They should be different. If your server didn't start, the last pgrep shouldn't have any output):

    Code:
    pgrep starbound
    pgrep starbound | xargs sudo kill
    pgrep starbound
    You'll probably also want to modify your update_starbound.sh script (from the original guide) to stop and start your server while you're updating it. Not sure what happens otherwise.
     
    Usiemon, flyinpancake and tab0reqq like this.
  2. tab0reqq

    tab0reqq Void-Bound Voyager

    Love ya !
     
  3. t0mi

    t0mi Space Hobo

    hi, this worked fine for me after todays update, now "sudo start starbound" does nothing? any troubleshooting?
     
  4. 1bitwonder

    1bitwonder Void-Bound Voyager

    Is there any output when you run the command?
     
  5. kreegah

    kreegah Big Damn Hero

    I've got this aswell, "sudo start starbound" does nothing? and there are no outputs
     
  6. Usiemon

    Usiemon Cosmic Narwhal

    Thanks for a great tutorial 1bitwonderer.

    Since the last Unstable update, you can't run starbound_server with an absolute path.
    As a workaround, you could try the following.

    Code:
    #!upstart
    description "Starbound"
    
    # Start the job
    setuid starbound
    chdir /home/steam/starbound/linux64
    exec ./starbound_server
    
    # Start on boot
    start on filesystem and net-device-up IFACE=lo
    
    # Restart the process if it dies
    respawn
    
    # Give up if restart occurs 10 times in 90 seconds
    respawn limit 10 90
    
     
  7. fieldsweeper

    fieldsweeper Space Hobo

    hey I dont know why but sudo never gets recognized, im using debian 7 runs fine i just want a simple auto restart script
    please help asap
     
  8. Sme4gle

    Sme4gle Pangalactic Porcupine

    this keeps giving me a job failed to start error, tried running this as different users, and I can only start my .starbound_server with user "steam" (which has sudo access), any ways to work this around?
     
  9. Usiemon

    Usiemon Cosmic Narwhal

    One possibility is that the user on which you want to run starbound_server does not have a right permission to Starbound directories.
    How does the syslog read when you try to start starbound_server?
     

Share This Page