FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.35k stars 72 forks source link

Systemd Service Requirements #59

Closed uvbeenzaned closed 2 years ago

uvbeenzaned commented 2 years ago

I attempted to create a simple systemd service file to bring it up on startup as my personal user and it just crashes with no useful errors. Any ideas what environment the process needs to work correctly as a service? Here is my service file:

[Unit]
Description=UxPlay Airplay Mirror Service
After=network.target
Wants=network-online.target

[Service]
Restart=always
User=me
Type=simple
ExecStart=/usr/local/bin/uxplay -s 1920x1080@144
Environment='XDG_RUNTIME_DIR=/run/user/1000'

[Install]
WantedBy=multi-user.target
fduncanh commented 2 years ago

Sound like a nice idea. I don't know enough about this to help.
I assume running uxplay -s 1920x1080@144 works fine (run from command line, not as a service) ? (default is 1920x1080@60)

You might want to test with -vs fpsdisplaysink to see what kind of framerate the streaming is at (default maxFPS is 30, maybe -fps 36 (144/4) or 48 = (144/3) might help if you have a fancy 144Hz refresh rate monitor (I didn't know those now ]existed, technology advances!) EDIT: I see 144Hz gaming monitors are common!

For 144Hz 72 fps is best, but I don't know if iOS device will deliver that

-fps n sets maxFPS=n as the maximum framerate the client is allowed to stream at, it doesn't force the client to stream at that rate, just forbids it from streaming faster.

uvbeenzaned commented 2 years ago

Thanks, I am mainly just looking to see what it takes to run as a service because it make much more sense for my use case to just have it always available. It didn't seem like 144hz was actually working on my high refresh rate monitors, it still seemed like 30fps. I will play with the settings you showed there. And yes, that command line did work fine from the shell without error. The service just seems to be missing something that the program expects. I have given it the XDG_RUNTTIME_DIR variable as you see and the service is set to run as my user but alas it crashes constantly. I will try my best to put the error I get into this issue here when I get a chance.

fduncanh commented 2 years ago

If you find the solution please reopen this issue (or post a new issue). It could help others!

closing for now.

markst commented 2 years ago

Hey @uvbeenzaned, this seems to be working for me.

[Unit]
Description=%p Service
After=service.system.docker.service
Requires=network-online.service
After=network-online.service

[Service]
Type=simple
ExecStart=/bin/sh /storage/.kodi/addons/%p/bin/%p
ExecStop=/bin/sh /storage/.kodi/addons/%p/bin/stop

[Install]
WantedBy=multi-user.target
monomycelium commented 2 years ago

@markst, can you share your start and stop scripts with us? Also, is /bin/sh necessary for running the scripts?

markst commented 2 years ago

@monomycelium https://github.com/markst/plugin.audio.uxplay/blob/main/bin/plugin.audio.uxplay

monomycelium commented 2 years ago

@markst, looking at your file, do you think this line of code from @uvbeenzaned in the service file would be enough to set the desktop environment, or should we set the environment differently?

Environment='XDG_RUNTIME_DIR=/run/user/1000'
fduncanh commented 2 years ago

Is this something that works generically, so could be added to the UxPlay package?

markst commented 2 years ago

@fduncanh quite specific to Kodi-LibreELEC I'd say. https://forum.libreelec.tv/thread/25200-uxplay-airplay-2-addon/?postID=166559#post166559

fduncanh commented 2 years ago

If someone wants to propose a generic systemd service configuration for uxplay that would be great!