Jellyfin Forum
Race condition between Jellyfin and NAS - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Race condition between Jellyfin and NAS (/t-race-condition-between-jellyfin-and-nas)



Race condition between Jellyfin and NAS - unmesh59 - 2024-10-16

I have Jellyfin running on Ubuntu on one server and a separate NAS with the media files. After a power outage, the machine with Jellyfin powers up first with the consequence that the SMB mount of the NAS fails and I have to run "sudo mount -a" manually after some time.

Is there a way to automate the sequencing of events so that the dependencies are met? 

I'd be willing to live with a single mount event firing a fixed time after reboot if deterministically waiting for the NAS to be up is too difficult.


RE: Race condition between Jellyfin and NAS - TheDreadPirate - 2024-10-16

You can modify the jellyfin service file to require that a mount be present before attempting to start.

Modify /etc/systemd/system/multi-user.target.wants/jellyfin.service and add "RequiresMountFor" in the [Service] section. I've provided an example below.

Code:
[Unit]
Description = Jellyfin Media Server
After = network-online.target

[Service]
RequiresMountsFor=/media/library
Type = simple
EnvironmentFile = /etc/default/jellyfin
User = jellyfin
Group = jellyfin
WorkingDirectory = /var/lib/jellyfin
ExecStart = /usr/bin/jellyfin $JELLYFIN_WEB_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT $JELLYFIN_ADDITIONAL_OPTS
Restart = on-failure
TimeoutSec = 15
SuccessExitStatus=0 143

[Install]
WantedBy = multi-user.target

I want to note that this will only work if you've defined your SMB mount in /etc/fstab. RequiresMountFor uses the fstab parameters to determine when the mount is actually available.


RE: Race condition between Jellyfin and NAS - unmesh59 - 2024-10-17

My fstab entry is
//192.168.1.206/Share1 /mnt/Syno cifs credentials=/etc/cifs-credentials

I expect I should replace /media/library in your example with my mount point which is /mnt/Syno

Also, my experience with power outages is that Ubuntu does not seem to retry the mount if it fails the first time and I have to automount using the fstab entry. Did I not wait long enough or will this change somehow cause the OS to retry mounting? Or something more has to be done on/to Ubuntu?

Thanks.


RE: Race condition between Jellyfin and NAS - TheDreadPirate - 2024-10-17

Yes, you'd replace /media/library with your mount location.

In your fstab you can try adding the retry option.

Code:
//192.168.1.206/Share1 /mnt/Syno cifs credentials=/etc/cifs-credentials,retry=5

This will retry for 5 minutes before giving up.


RE: Race condition between Jellyfin and NAS - unmesh59 - 2024-10-17

Awesome! I will add that and wait for the next power outage which may not be too far away :-(