- Home /
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
Answer by any_user · Nov 27, 2012 at 03:41 PM
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).
Cool, even better workaround. $$anonymous$$ight come handy at some point. We'll see whether this is needed anymore when the next unity build comes out.
Just a comment for people wandering in now -- in Unity 4.something they added better headless linux support that doesn't require X11. The supported way to do this now is to build the app with the "Headless" checkbox checked in Unity. Then you don't need an xvfb session, nor even the "-batchmode" parameter.
On the down side, the old way doesn't seem to work correctly anymore -- the "-batchmode" parameter is supposedly still supported for Linux, but I haven't gotten it to do anything. This means if you really wanted to use one Linux build for both headless and regular gameplay, you seem to be out of luck.
Answer by mtoivo · Nov 24, 2012 at 09:27 PM
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.
Ok thanks, that worked basically, I was able to start the application with ssh -X user@server. But how can I start it and log off with the server still running? Looks like I need to keep X11 open.
I guess you would need some kind of X11/VNC-solution for that to work. You could probably log in from console, start X11 session and fire up VNC-server there. It shouldn't be hard to set up a 'virtual' X11 session inside the server, that doesn't require a real X11 running. Something like this, perhaps: http://www.karlrunge.com/x11vnc/
Answer by jcongote.unity · Apr 11, 2013 at 03:21 PM
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
Answer by nan · Oct 08, 2013 at 11:27 AM
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 ?
Change the port to 25050, I had the same error on Lubuntu with a unity game, and the port was being used already by a different process
Answer by _Mathias · Jul 16, 2015 at 09:54 PM
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
Your answer
Follow this Question
Related Questions
Linux game server 1 Answer
Headless linux server 2 Answers
Unity server on Amazon EC2 Ubuntu? 2 Answers
Batchmode on linux 1 Answer