- Home /
How to autostart Ubuntu headless server?
There must be people here who run their game servers on Ubuntu servers? How do you start the program when the server starts? I can run it with ./Servername.x86_64 but that's all I know about running programs in Linux. This method is not good because the server will not start if a reboot happens, also the program is tied to the SSH terminal window - if I close it the program closes with it.
I'm also trying to run my server with upstart, but I get this error:
Got a SIGABRT while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.
Again, it runs fine if I cd to the directory and run ./Server.x86_64 but that same command does not work trough upstart.
My upstart script:
start on runlevel [2345] stop on shutdown
console log
script chdir /home/tuomas/server exec ./Server.x86_64 end script
Answer by tmammela · Nov 29, 2015 at 09:52 AM
Okay, I got it working. I'm so confused right now that I don't know what is going on, but here is how I start it now:
In /etc/rc.local I added this line:
su tuomas -c "screen -dm -S VCPR bash -c '/home/tuomas/run_server.sh;exec bash'"
It runs screen terminal multiplexer as a user and then in that screen session the starting script is run. exec bash makes sure that the screen session won't exit...
It is important to run as a user not as root, for some reason I get mono errors if run as root.
My run_server.sh is very simple:
#!/bin/bash
echo "Starting VCPR server"
echo
sleep 2
exec /home/tuomas/server/Server.x86_64 -logfile /home/tuomas/server.log &
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Photon and Playfab 0 Answers
How do I ApplyDamage to a specific player across network 5 Answers
Networking RPC calls never sent to other clients 1 Answer
Multiplayer push object error. 0 Answers