INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Systemd Services for JRiver (To Facilitate Running Headless on Linux)  (Read 1908 times)

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5233
  • "Linux Merit Badge" Recipient

Here's a systemd service that will automatically start jriver on boot as your user (after the display manager loads), and if JRiver should crash, restarts it within 10 seconds.  This will work best on systems with autologin, but because of the restarting feature, should work fine even if it has to wait for you to login.  You want to put your username in the "user" spot, and put the following text in a file at /etc/systemd/system/jriver.service:

Code: [Select]
  [Unit]
     Description=JRiver
     After=display-manager.service

  [Service]
     Type=simple
     Environment=DISPLAY=:0
     User=your_user_here
     ExecStart=/usr/bin/mediacenter25 /MediaServer
     Restart=always
     RestartSec=10
     KillSignal=SIGHUP
     TimeoutStopSec=45
     LimitRTPRIO=100

  [Install]
     WantedBy=graphical.target

Some technical notes: 

If you want MC to wait until the network connection is available before starting, you can add "network.target" after display-manager.service in the third line, separated by a space.  This may prevent JRiver from starting if there are network issues, however, so make sure that's the behavior you want.

This unit presumes you're running on your actual display, not a virtual display generated by a VNC client.  If you are using such a virtual display, substitute the display variable in the Environment section, and change the "After" line to refer to the name of the systemd service you're using to start your vnc server, but note that VNC virtual displays may not work correctly anymore with MC since 22.0.36. 

In that vein, here's a service to start x11vnc to allow remote access to your actual display on boot.  It similarly will restart if it crashes.  You want to put your username in place of both of the "your_user_here" placeholders below, create a file at /etc/systemd/system/x11vnc.service, and put the following text there:

Code: [Select]
[Unit]
     Description=x11vnc
     After=display-manager.service

  [Service]
     Type=forking
     Environment=DISPLAY=:0
     User=your_user_here
     ExecStart=/usr/bin/x11vnc -rfbauth /home/your_user_here/.vnc/passwd -display :0 -geometry 1920x1080 -auth guess -forever -bg
     Restart=always
     RestartSec=10

  [Install]
     WantedBy=graphical.target

Technical notes: this presumes that you've already setup a VNC password.  If you want to run without a password remove the -rfbauth flag and the path following it.  If you want to set a password run the following command replacing "your_password" with your password:

Code: [Select]
x11vnc -storepasswd your_password ~/.vnc/passwd

Once you've got the services in place you can set them to start on boot by typing
Code: [Select]
sudo systemctl enable jriver.service
and/or
Code: [Select]
sudo systemctl enable x11vnc.service
Logged

lowjoel

  • World Citizen
  • ***
  • Posts: 159
Re: Systemd Services for JRiver (To Facilitate Running Headless on Linux)
« Reply #1 on: August 02, 2019, 09:03:44 pm »

I've been aggregating the content for headless Media Center over the past few versions (I went all the way to the MC20 forums...) for a headless server. The server is a VM running Ubuntu Server (like a cloud instance), so there's no video device on the system at all.

These systemd services were useful for getting me started, but x11vnc didn't seem to properly expose an X session that Media Center liked (despite using the -create option).

I ended up using a combination of tigervncserver (in place of x11vnc) and fluxbox (in place of openbox) as a super minimal environment for Media Center to run, which works well enough for me. I fundamentally still used two services, one to start the X display and the other to start Media Center.

References:
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5233
  • "Linux Merit Badge" Recipient
Re: Systemd Services for JRiver (To Facilitate Running Headless on Linux)
« Reply #2 on: August 02, 2019, 10:15:38 pm »

I've been aggregating the content for headless Media Center over the past few versions (I went all the way to the MC20 forums...) for a headless server. The server is a VM running Ubuntu Server (like a cloud instance), so there's no video device on the system at all.

These systemd services were useful for getting me started, but x11vnc didn't seem to properly expose an X session that Media Center liked (despite using the -create option).

I ended up using a combination of tigervncserver (in place of x11vnc) and fluxbox (in place of openbox) as a super minimal environment for Media Center to run, which works well enough for me. I fundamentally still used two services, one to start the X display and the other to start Media Center.

References:

Interesting. x11vnc still works fine for me on my headless systems, but my systems do have video hardware, it just isn't connected to anything.  x11vnc in my case is sharing the actual output of the video device (if I plug in a monitor I can see the VNC session at work), so that may be the distinguishing feature.

Is the tigervnc dummy display working well with MC now?  I used to use tigervnc to create a display, but it broke sometime after MC23 (it created a lot of weird windowing issues that made it impossible to interact with all of MC's option windows) and I never returned to it to see if MC worked well with it now.  For example, the options window and the DSP studio window were challenging to interact with if I recall correctly.  It'd be nice if it just worked now  ;D
Logged

lowjoel

  • World Citizen
  • ***
  • Posts: 159
Re: Systemd Services for JRiver (To Facilitate Running Headless on Linux)
« Reply #3 on: August 02, 2019, 10:20:49 pm »

Interesting. x11vnc still works fine for me on my headless systems, but my systems do have video hardware, it just isn't connected to anything.  x11vnc in my case is sharing the actual output of the video device (if I plug in a monitor I can see the VNC session at work), so that may be the distinguishing feature.
Yeah. This VM doesn't have any video devices (not technically true, since there's console output, and in theory I could get it to display some GUI), but for all intents and purposes yes, nothing's plugged in.

Is the tigervnc dummy display working well with MC now?  I used to use tigervnc to create a display, but it broke sometime after MC23 (it created a lot of weird windowing issues that made it impossible to interact with all of MC's option windows) and I never returned to it to see if MC worked well with it now.  For example, the options window and the DSP studio window were challenging to interact with if I recall correctly.  It'd be nice if it just worked now  ;D
How does the screenshot look? I had bad windowing problems when I don't have a window manager running (just xterm... which isn't a window manager...). I installed fluxbox and that took care of it.
Logged
Pages: [1]   Go Up