How can a unity game be started on headless linux servers?

I try to run a server build of a unity application on an Ubuntu Server (12.04). It doesn’t work when I try to start the application with:

./myUnityApplication -batchmode

Following error occurs (Player.log):

Display is invalid  
Failed to initialize ScreenManager

Now that I found the answer myself, here it is:

You can run unity applications on headless linux systems (eg. servers) by running the application with xvfb (x virtual frame buffer http://manpages.ubuntu.com/manpages/precise/man1/Xvfb.1.html):

On ubuntu server 12.04 i had to install following packages:
apt-get install libglu1
apt-get install xvfb
apt-get install libxcursor1

then I was able to run unity applications with this command:

xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' myUnityApplication -batchmode

it’s important to run the virtual screen buffer in 24 or 32 bit mode (eg. 640x480x24 or 640x480x24:32) else it will not work (xvfb default is 640x480x8).

Batchmode needs X11 session anyway. If you’re using mac, it’s easily achieved remotely (although I haven’t tried this). Fire up your X11.app or XQuartz.app with newer OS’s, use ssh -X user@ubuntuserver and there you go. On windows, you’d need some sort of X11 server running, too, but it’s been a while since I’ve played with those.

Sometimes the application don’t run in Xvfb for GLX, the solution for Unity 4.1 and later is to add -nographics argument

xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' myUnityApplication -batchmode -nographics

Hi,

I think my UnityApp is run correctly:

Logfile

ALSA lib confmisc.c:768:(parse_card) cannot find card ‘0’
ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_concat returned error: No such file or direcFMOD failed to initialize … Error initializing output device.

(Filename: Line: 177)

Begin MonoManager ReloadAssembly
Platform assembly: /multi_test/multi_Data/Managed/UnityEngine.dll (this message is harmless)
Loading /multi_test/multi_Data/Managed/UnityEngine.dll into Unity Child Domain
Platform assembly: /multi_test/multi_Data/Managed/Assembly-CSharp.dll (this message is harmless)
Loading /multi_test/multi_Data/Managed/Assembly-CSharp.dll into Unity Child Domain

  • Completed reload, in 0.140 seconds

but i Cant connect to it on port 25000.
any idea ?

Hello,

I need your help please. I try to install a server for my game on my debian server, and the game file is called “server.x86”. When I replace “myUnityApplication” to “server.x86” in
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' myUnityApplication -batchmode

it returns an error:

/usr/bin/xvfb-run: 183: /usr/bin/xvfb-run: server.x86: not found

I tried with the x86_64 extension but it still doesn’t work. I built this application in Headless mode.

If somebody could help me it would be very nice !
Thanks in advance

It is saying that the file does not exist in that directory, do you have server.x86 in the xvfb-run directory? Also shouldn’t your executable be a .exe file and not a .x86? That second part is just a question not a suggestion.