Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

xorg - How to run multiple applications that need x server in headless ubuntu server?

I have a single graphics card in a remote headless ubuntu server. I have set nvidia-xconfig to make a virtual display. I need virtual x server, but not xvfb, to run a unity game headless, yet record a video of rendering of the game. Xvfb does work fine, but it does not use graphics card, which makes rendering very slow.

This works fine with xinit if I run a single game.

xinit ./game.x86_64 Starts game and renders game play without any problem.

However, when I try to start multiple games simultaneously with different x-servers:

xinit ./game1.x86_64 -- :0

xinit ./game2.x86_64 -- :1

This does not render properly. One of the game (the one that started first) does not render. (Checked with the recorded video) As far as I know, this is because a single graphics card can only have a single x-server running.

Then, I set multiple screens by tweaking xorg.conf and tried

xinit ./game1.x86_64 -- :0.0

xinit ./game2.x86_64 -- :0.1

However, since xinit tries to start a new server, the latter one does not work, telling there's already an x-server running at X:0

If I search for multiple monitor x-server setting, what I can find is real monitor setup only, yet what I need is virtual monitor setup.

Is there a way to start multiple applications that need a screen in a headless server?

What I think I need to know is

  1. A way to start a x-server with multiple screens and tell the application to use which screen OR

  2. A way to use windows manager remotely on console

If there's any better solutions, or if I have missed something, it would be really helpful too.

question from:https://stackoverflow.com/questions/65870117/how-to-run-multiple-applications-that-need-x-server-in-headless-ubuntu-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was misunderstanding how xinit works. I figured this out by running xinit without any clients in the background (like tmux)

xinit or xinit -- :0

and then, specifying which display to use. Of course, multiple monitors are set in xorg.conf. For unity, it was enough to just exporting display environment variable.

export DISPLAY=:0.0 for game1

export DISPLAY=:0.1 for game2

The log says unity recognizes both display, but game1 says

:0.0 display is 'display 0 (Primary display)'

while game2 says

:0.1 display is 'display 0 (Primary display)'

My misunderstanding was that I thought xinit is only used with client application, although xinit can run without any client application and just running in the background.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...