How to reconnect to a background GUI application after session disconnect? - linux

We have Eclipse setup as our IDE on a central Linux server. Everyone will connect to the server, opens an Eclipse instance, work on it.
Eclipse will be run as a background process, showing the GUI to the user.
What happens is, sometimes people disconnect from the SSH session abruptly(making the laptop to sleep ..etc), without properly closing eclipse, which sometimes leaves the Eclipse process running in the background.
Whenever the user tries to connect next time, they are unaware of the existing Eclipse sessions, and continue starting a new one, while the existing Eclipse processes continue running in the background taking up all the resources.
Question is, can we re-connect to that abandoned Eclipse session somehow? Is it possible to bring up the Eclipse in the same state where user left it?
I looked at GNU screen . However, it can't bring the GUI application back to the user.

This seems to be a problematic setup to me. Why not work on the local computer in the first place? But if you want (or have to) to work on the server, better start the desktop directly on the server via XDMCP, VNC, or Citrix XenAPP (commercial).
EDIT: Just found this article about xmove. I haven't heard about it before, but maybe it works.

Related

How do I reopen an open program on a linux server, with ssh connection in Powershell

Basically I have a linux server, that I can connect to using ssh -i *pvKey* *user#host*.
When I'm connected I can open a java application, like I have. The linux server stays open 24/7 and I believe any application I open does the same. How do I reopen an open application if I close windows powershell.
Let's say I go to bed and close windows Powershell, I believe the java application will stay open during the night, which is what I want. How do I reopen that java program again after connecting to the server, so I can continue sending commands in the java application.
For more specific information: The java application I'm talking about is a minecraft server, which I want to leave on 24/7 (with some restarts obv). I want to be able to reopen the java program of the mc-server that has stayed open, so that I can send more commands and possibly restart the mc-server, without having to log into it in minecraft, stopping it, and reopening it in powershell.
This is the first time I try to work with a linux server and powershell, so please excuse my lack of knowledge.
Your remote shell automatically kills all processes that are running in the shell when you exit the shell.
I would probably use screen for this usecase.

Running GUI without need of remote desktop connection on-going

Build: Server with Ubuntu 18.04 in data center with Ubuntu Mate Desktop interface.
As I understand, any GUI app needs a display in which to function. I connect to the server via x2go to display the ubuntu mate interface.
Once connected, I have a scheduled cron job that launches a terminal, a GUI and some commands.
Everything works perfect as I have previously detected what display I'm using as a user and specify that to launch the terminal and the commands.
Problem: if I'm not connected via x2go client to the server and provide that display, I noticed today that the cron job didn't launch at the specific time (08:50), which was previous to my x2go client connection (09:23); it just launched when I did the x2go client connection from my desktop manually -- my understanding is that it didn't launch because there was not any available display.
I'm not technical enough to get more deep into this problem.
¿Is there anyway in which I can make the cron script function (i.e. that it launchs the terminal and the GUI) without the need of manually getting into my desktop and launching the remote desktop client (x2go)?
My ideas go for having another minimal setup in that data center or another that takes the advantages of being there and have a physical monitor to display constantly connected to the main server OR just manually entering the server via x2go every day.
EDIT: When I disconnect the x2go client session from the server, the launched GUI and etc perfectly maintains, without dissapearing because "I have terminated the session and eliminated the display".
Finally got it working with the great help of one of x2go founders (Oleksandr Shneyder) after understanding how x2go handles the sessions and the X server.
Sessions can suspended/hibernated, disconnected and terminated.
Suspended/hibernated: when "manually" or automatically the x2go server side suspends so that it saves resources.
Disconnected: when you exit the session window and the x2go client in your desktop/laptop.
Terminated: when you log out from the DE environment or issue the x2goterminate-session command in the terminal inside the session.
My x2go app was somehow entering into suspending mode in the server, causing that the display (50 in my case) in which the scheduled cronjob need to be run and launche the GUIs, "was not awaken" until I entered into the session via the
app. In that moment, the cronjob started executing.
To tell x2go server to not hibernate, I needed to change the X2GO_NXOPTIONS in /etc/x2go/x2goagent.options to X2GO_NXOPTIONS="sleep=0"
After this, everything functions perfectly in the server.
Hope it helps others.

Does a window need a graphical environment to exist?

This one is a pretty strange question of mine so I'll try to explain the best I can.
On a DOS Linux distribution, without having installed any graphical environment, if I start an application which is supposed to have a GUI, will I be able to interact with that window via code?
What I thought is that if KDE/GNOME's role is to graphically represent an existing GUI, I should be able to interact with it but if these graphical environments have an active role in the window creation there is nothing I can do.
You won't be able to run a graphical program without a window manager.
The reason is that the window manager is doing a lot more than just allowing the window to be shown to the user. It comes with libraries and services for constructing windows and components and interacting with them. Without these libraries and services, the program won't be able to start.
The only exception would be if a program contained all the graphical code built into it, and didn't rely on a window manager. Realistically this would only happen for a fairly simple program and in special cases; for instance, Raspbian includes OMXPlayer, which shows full screen video without relying on any window manager.
Quoting (with some adaptation) from https://raspberrypi.stackexchange.com/a/3974 which answers how to start mplayer in X11 without a window manager:
The X server is really usually called X and you can just start it. You can set the DISPLAY number as an argument along with some other things.
You might want to have some sort of session, though, and still go through xinit or such and start X with startx. You can use .xinitrc or such as a script and simply not start a window manager there. You will need a "magic client" as the last command that stays running so X doesn't terminate immediately. In a traditional "failsafe" session, that was an xterm. If you know what to launch and launch once only, it could be that program or any UI/wrapper that does the launching for you. When the last ("magic") client in the init script terminates, X terminates.
If all you want to do is play video, you might see if you can run mplayer with directfb instead and skip using X11 entirely.

Keeping a X11 application alive, which I can disconnect from and reconnect to afterwards

I currently have a tiny, headless (and I certainly want to keep it that way :) ) Linux Virtual Machine set up with Vagrant and VirtualBox which, for testing, I want to run an X11 application (Firefox) whose output comes to Xming on my real machine. All that's hunky dory, working perfectly, but I'm not happy yet!
What I want to be able to do is do a few setup things, make sure everything's running correctly, then disconnect from the server and let the testing run it's course. If however something goes wrong, or I want to just check the current status of things (some of the tests may run into hours), I'd like to then hop back onto the server and point the X11 output to my machine again. But despite a good deal of Google-ing and learning loads about X11 that I didn't know a few hours ago, I can't find anything about choosing where the output of an X11 application goes, except at startup, ie;
DISPLAY=:10 firefox &
I had read some random blog post that Xephyr XServer did this (kind of act as an intermediate X11 buffer, which then redirects if you want it to, otherwise just outputs to /dev/null), but I can't find any other reference to it, or anything else doing that.
There's a program called Xpra that works sort of like "screen" but for X-sessions. It would start a separate X session from the main one, for the remote access, but you can connect/disconnect to it at will from the host machine.
http://www.xpra.org/
I currently have one acceptable way to do this, which will serve my purpose, I have a vnc4server running that takes firefox's output, and then I can connect and disconnect to that without any issue at all, just like a normal VNC server. This allows me to do what I want to do, but not how I want to do it. I'd like to be able to do this without the need of a VNC server at all.

OpenGL / X-Window program hangs during Window creation

I've got a C/C++ app using the GLFW Library on a netbook-like device running Ubuntu 8.10.
As far as I understand the source the GLFW lib, it creates its window using calls to the X-Window library.
We do not use any desktop on the machine but login to a tty and start a X-server in the background. When running the compiled application from a tty* on the target platform during the call to
glfwOpenWindow( ... );
glXQueryExtension( ...);
_glfwChooseVisual( ... );
XGetVisualInfo( ... );
the application halts. It does NOT crash. When switching to the X-Window by hitting Ctrl+Alt+F7 the application continues normally.
What could cause this weird behaviour?
BEGIN_EDIT:
Now I am quite sure the problem is related to the configuration of either Ubuntu or the x-server. When I try to run
glxinfo
in the shell the command also hangs until I switch to the X-window by hitting CTRL+ALT+F7. When I return to my shell after hitting the keys the command has finished.
Could it be that the X-server is put to 'sleep' when in console mode?
END_EDIT;
If the X window server runs in the background, it (obviously) doesn't own the display. Thus it can't reply to requests until its back in the foreground.
That would be my expectation at least. You can't ask a display server to open a window, if that display server is not actually owning the display hardware at the time of the request.
Blocking until it gets control of the hardware back sounds totally sensible to me.
Is a login manager running on the X server? They typically will grab the X server for exclusive use. Try logging in and see if that makes a difference.

Resources