mmatyas / pegasus-frontend

A cross platform, customizable graphical frontend for launching emulators and managing your game collection.
http://pegasus-frontend.org
Other
1.21k stars 109 forks source link

Pegasus does not run as a service in Libreelec Amlogic S905 #177

Closed shantigilbert closed 6 years ago

shantigilbert commented 6 years ago

if you create a service to run Pegasus it will not run

[Unit]
Description=Pegasus emulator frontend
ConditionPathExists=/var/lock/start.pegasus

[Service]
Environment=HOME=/storage
ExecStartPre=/usr/bin/pegasus-config
ExecStart=/usr/bin/pegasus-fe
KillMode=process
TimeoutStopSec=3
Restart=on-failure
RestartSec=2
StartLimitInterval=0

[Install]
WantedBy=kodi.target

if I run it like:

touch /var/lock/start.pegasus
systemctl start pegasus.service

nothing happens, if I run systemctl status I see pegasus quits with error (code=exited, status=127).

If i run it with systemd-run it complains it can't find the shared QT5 libraries even though they are in the library path.

If run the program directly like /usr/bin/pegasus-fe everything works fine.

Note that this might not be a problem with Pegasus, but other programs run fine with the same or similar service configuration (e.g, retroarch, emulationstation, reicast, ppsspp and advmame are the ones I've tried)

mmatyas commented 6 years ago

Have you tried running it like this on other devices (desktop, Raspberry Pi, etc.)?

If you run it with systemd-run, I think you have to make sure the lib paths are visible for the root user, probably by setting Environment=LD_LIBRARY_PATH=something, or by installing the Qt shared objects to the same place as the other system libs.

Unfortunately I'm not too familiar with systemd services or Kodi; if possible, I'd recommend trying a different approach, as the concept of services/daemons isn't really for running full-screen applications in the foreground, in my opinion. Instead, sending Kodi to the background, then launching a program the usual way would seem better to me. Of course, correct me if I'm wrong.

Also if you can point me where to get a sysroot + toolchain and what flags were needed for Qt to run on the S905, I can try creating a static build too.

shantigilbert commented 6 years ago

I have not tried to run it on any other device yet, I have a Raspberry pi but its still in the box.

I tried setting the path before I ran pegasus still no dice, I have not tried moving the libs, will try that.

Kodi really has nothing to do with it, its more Libreelec. I understand that the concept of daemons is to be run as background apps, but in this case in order to make it play together with a system that mainly has one program running full screen is something that is needed as a workaround, this is how we do it with ES and RA.

Sure traditionally it should work like that, send the parent to the background and run the child but if I send Kodi to the background it kinda works, but I can see some emulators loosing frames, not a lot of them but you can notice the difference, so I was trying to avoid that.

This is the package I use on Libreelec to compile Pegasus https://github.com/shantigilbert/LibreELEC.tv/blob/Sx05RE_8.2_PE/packages/sx05re/pegasus-frontend/package.mk

and this is the one that includes all the flags for QT https://github.com/shantigilbert/LibreELEC.tv/blob/Sx05RE_8.2_PE/packages/sx05re/pegasus-frontend/qt-everywhere/package.mk

I appreciate you taking the time to help on this, I understand this is not something that Pegasus should do and the problem is mostly on my side.

mmatyas commented 6 years ago

I see; not sure how much I can help, but I've just started building your repo, maybe fixing the lib issues will make the services work too.

shantigilbert commented 6 years ago

Thanks.

I apologize, I posted the wrong links (now edited) as I am using a different branch to work on Pegasus

https://github.com/shantigilbert/LibreELEC.tv/tree/Sx05RE_8.2_PE

But the files are basically the same.

shantigilbert commented 6 years ago

Progress:

I mande a symlink to the libraries under /usr/lib and now it find them. But now it does not find the plugin path :/

I can't seem to make QT compile and use /usr/lib as prefix, I think that will solve the issue. I will continue to play with this and see if I can find a solution.

shantigilbert commented 6 years ago

Well I did several things, I upgraded to QT 5.9.4, and a few other things not sure if a combination of of them or what but in the end I think creating a new service and passing the variables directly worked.

[Service]
Environment=HOME=/storage
Environment=LD_LIBRARY_PATH=/usr/lib:/usr/lib/pulseaudio:/usr/local/qt5/lib
Environment=PATH=/usr/bin:/usr/sbin:/usr/local/qt5/libexec
Environment=QML2_IMPORT_PATH=/storage/plugins:/usr/local/qt5/qml
Environment=QT_PLUGIN_PATH=/usr/local/qt5/plugins
Environment=QT_QPA_EGLFS_DEPTH=32
Environment=QT_QPA_EGLFS_PHYSICAL_HEIGHT=135
Environment=QT_QPA_EGLFS_PHYSICAL_WIDTH=217
Environment=QT_QPA_FONTDIR=/usr/local/qt5/lib/fonts
Environment=QT_QPA_PLATFORM=eglfs
ExecStartPre=/usr/bin/pegasus-config
ExecStart=/usr/bin/pegasus-fe
KillMode=process
TimeoutStopSec=3
Restart=on-failure
RestartSec=2
StartLimitInterval=0

Thanks for all your help I can now enjoy Pegasus on my build :D

mmatyas commented 6 years ago

Nice!