More > JRiver Media Center 23 for Linux

Systemd services to autostart JRiver and a VNC server

(1/3) > >>

mwillems:
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: ---  [Unit]
     Description=JRiver
     After=display-manager.service

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

  [Install]
     WantedBy=graphical.target

--- End code ---

Some technical notes:  this 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: ---[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

--- End code ---

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: ---x11vnc -storepasswd your_password ~/.vnc/passwd

--- End code ---

Once you've got the services in place you can set them to start on boot by typing

--- Code: ---sudo systemctl enable jriver.service

--- End code ---
and/or

--- Code: ---sudo systemctl enable x11vnc.service

--- End code ---

astromo:
Nice.

You're doing a great job to add another merit badge to your collection.

Will keep this in mind when I the opportunity to tinker presents.

tombert:
I would like to note for others that display-manager.service is a link to lightdm.service (at least in Ubuntu 16):


--- Code: ---lrwxrwxrwx  1 root root   35 Sep  7 22:03 display-manager.service -> /lib/systemd/system/lightdm.service
--- End code ---

At least on my system mediacenter23 did not start reliable (sometimes yes, more-often no):
Replacing the line:

--- Code: ---After=display-manager.service
--- End code ---
with:

--- Code: ---After=lightdm.service
--- End code ---
seems to work better.

Also I would recommend to replace:

--- Code: ---Restart=always
--- End code ---
with:

--- Code: ---Restart=on-failure
--- End code ---
This way one can shutdown MC without it being restarted automatically.

mwillems:

--- Quote from: tombert on September 14, 2017, 04:36:05 pm ---I would like to note for others that display-manager.service is a link to lightdm.service (at least in Ubuntu 16):


--- Code: ---lrwxrwxrwx  1 root root   35 Sep  7 22:03 display-manager.service -> /lib/systemd/system/lightdm.service
--- End code ---

At least on my system mediacenter23 did not start reliable (sometimes yes, more-often no):
Replacing the line:

--- Code: ---After=display-manager.service
--- End code ---
with:

--- Code: ---After=lightdm.service
--- End code ---
seems to work better.

--- End quote ---

display-manager.service is always linked to the display manager for the distro.  On ubuntu it's lightdm, on debian its gdm (by default), on fedora gdm, etc.  So display-manager.service is guaranteed to point to the right place, and is the correct general purpose answer.  As a symlink it's interchangeable with the thing linked to, so it's would be very unusual if you're actually seeing different results with "after=lightdm.service," but if you are there is something peculiar about your install.

Additionally the always auto-restart should be bringing MC up shortly if it doesn't succeed in loading the first time (unless you changed it to "on failure" as you described, because systemd doesn't always do a good job of distinguishing failure-based shutdowns)


--- Quote ---Also I would recommend to replace:

--- Code: ---Restart=always
--- End code ---
with:

--- Code: ---Restart=on-failure
--- End code ---
This way one can shutdown MC without it being restarted automatically.

--- End quote ---

I initially tried that, but my experience was that some of MC's failure modes do not successfully hook "on-failure", so I'd get crashes where MC would never respawn.  I was using this primarily on headless systems, so "always" was a safer choice.  If you want to stop MC on a system with the "always" option, there's always "systemctl stop jriver.service"

Awesome Donkey:
Ubuntu 17.10 is switching to gdm from lightdm.

Navigation

[0] Message Index

[#] Next page

Go to full version