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

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

chdir /home/tuomas/server
exec ./Server.x86_64
end script

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/;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 is very simple:

echo "Starting VCPR server"
sleep 2
exec /home/tuomas/server/Server.x86_64 -logfile /home/tuomas/server.log &