Automatic Library Updates

Server Version#: 1.19.4.2865
I recently had to reinstall Plex on my Freenas server. After reinstalling I noticed that my libraries were not updating like they used to. Before the reinstall I had Scan my library automatically and Run a partial scan when changes are detected selected and everything worked fine. Whenever a new media file was added to one of the libraries Plex would pick it up within minutes.

After the reinstall I have the same options selected, Scan my library automatically and Run a Partial Scan when changes are detected. However I I noticed the library was not being updated after items were added. I can do a manual scan and it will pick up new items. I have also tried it with Scan my library periodically and it would work, however doing that scans my music library as well which rarely changes and it rather large so it takes quite a bit of time.

My question is there anyway to get the Scan my library automatically and Run a Partial Scan when changes are detected working again.

Or can I have Plex not scan the Music Library each time it does a periodically scan.

I have attached logs. Any suggestions or help will be appreciated.

Thank you

Plex Media Server Logs_2020-05-31_14-17-32.zip (4.9 MB)

Sounds like you exceeded the number of directories your Linux is monitoring for you by default.

Meanwhile, we’re not on Linux…

fair point… though… isn’t there a Linux/FreeBSD under the hood of FreeNAS?

It’s funny because according to @mikec_pt, Plex on FreeBSD never supported this, but I seem to recall it did work, and here’s someone else saying the same thing.

It did work, I have used Plex for years on Freenas and it always worked. I have even had to reinstall in the past and it kept on working until this time.

Again this never worked natively in PMS, not with FreeBSD you were likely dong this via some script/3rd party software.

If we never added code for this how could it have worked? The approach we use for linux is not supported by FreeBSD and AFAIK never was.

One of our devs attempted to look into using kqueue and it wasn’t worth it, see Properly implement kqueue to allow PMS to auto-update library on filesystem change (FreeBSD) (back in 2016), so please trust me this never worked and unless FreeBSD adds support to inotify I’d say its unlikely too, this is actually the case with other software’s its one of the biggest gotchas in porting to BSD.

I am a use and fan of BSD for years and this is one of those things I really which they improved on. I looked into fswatch, for reasons other then plex since it cross platfroms and found that it still uses kqueue as a backend and so as similar limitations:

The kqueue monitor, available on any *BSD system featuring kqueue, requires a file descriptor to be opened for every file being watched. As a result, this monitor scales badly with the number of files being observed, and may begin to misbehave as soon as the fswatch process runs out of file descriptors. In this case, fswatch dumps one error on standard error for every file that cannot be opened.

FreeBSD is IMHO better than linux in many things, but this is by far not one, and from what I’ve picked up on mailing lists/forums there’s no plans on improving this soon :frowning:

That said depending on how you add media it shouldn’t be hard to automate calling the scan on a library (tools like sonnar i.e. do this)

1 Like

I wonder… could this be around the time FreeNAS was experimenting with virtualized containers or what was it!? but that would rally be Linux not FreeBSD/FreeNAS(you wouldn’t be running plex in freenas or a jail but a Linux VM basically)

Maybe that was it? But that never got to the point of being official and they decided not to move in that direction, much less was Plex officially supported on it. Yet its the only thing remotely closing to this working “inside” FreeNAS that I can thing off. (Which would be the same as saying you got it working on windows while runing plex on a Linux virtaulbox VM).

I will fully concede that you have a lot more knowledge than me when it comes to Plex and Freenas. But I am telling you it worked. How it worked I don’t know. I did not have any scripts running as I have never set up any scripts and to be honest wouldn’t even be sure how to without researching it first. I have always used the Plex Plugin for Freenas. I have reinstalled a number of times over the last few years and every time the I would use the Plex Plugin. The only thing I did different this time was use the Plex Media Server (Beta) plugin instead of the Plex Media Server plugin. I use the beta plugin because I have Plex Pass and when I would update Plex I would do it through the jail using the instructions found here.

I plan to reinstall this weekend and try using the Plex Media Plugin since that is the only thing I know that could be different.

The plugin (at least currently just installs packages to the jail) so its rally just the same!

Back in the old days the packaging system was different but PMS it self never supported it.

If you do recall the version of FreeNAS/Plex where this was workings for you maybe you can point me to it and I can maybe guess how it was done, but it wouldn’t be by PMS code it self that much I can say which is what ultimately I assume you wanted!

This is actually why I use sonarr in another jail, it monitors the same dirs, and connects to PMS (via plex.tv account) and just sends a refresh call to PMS API when new media is imported (this way I don’t need a custom script, or go to the web UI, a few secs after its update on the clients - might be a bit overkill for just this task but it works)

There is actually a plugin for sonarr to on FreeNAS (which simply installs it into a new jail), would that work for you in future?

That would have been FreeNAS 10 and the whole Corral/Docker thing. I was never involved in that. At the time I was running FreeNAS 9.2 because the later versions required you to use ZFS, which my hardware could not support properly. Then I built a whole new system later on and I jumped to FreeNAS 11.

The period where automatic updates worked was not that long ago anyway, I mean like just a few months for me, like back when I was on PMS 1.16 (under FreeNAS 11) – anyway, if you say it didn’t work that’s fine. :man_shrugging: I never used any third-party scanning utilities. I do have Sonarr, but I normally manage my media manually and Sonarr has its own directories on the pool for the content it manages.

Here: https://downloads.plex.tv/plex-media-server-new/1.16.6.1592-b9d49bdb7/freebsd/PlexMediaServer-1.16.6.1592-b9d49bdb7-FreeBSD-amd64.tar.bz2

If you can compile the port using that you can give it a go, I can also fetch older versions that would work for FreeBSD 11.3+++ (or possibly 11.1/2 back than) all should work fine on 11.3/12 anyway.

If you want to give it a go (I suggest in a clean jail with ports fetched) you just need to place the file in /usr/ports/distfiles;
cd /usr/ports/multimeida/plexmediaserver
Edit the PORTVERSION/DISTVERSIONSUFFIX in the Makefile to match the version-hash;
make makesum and make package

This will create a ready to install txz via pkg install

Again I can also fetch other builds, I’m not sure how easy it is to get a FreeNAS 9 in a VM too (last plugin build there was 1.9 at most btw and its not upadted in years not months. The last 1.16 is also from almost a year ago (august) but FreeNAS might take a bit more to cathc up.

Honestly I’m happy to give any past builds so you can verify this, but I promise this is just not supported natively in plex and will likely never will unless a lot of things change in BSD world or the huge resources usage this could cause is no longer an issue.

Please let me know if you want to go down that route, if not I think we can just close this.

I last had it working about 3 weeks ago. I am rather OCD about keeping everything up to date so I would have been whatever Freenas version and Plex Pass version was available. I don’t recall what was I was on at the time.

I am going to test a few things and see if I can figure out how it was updating before. If I can’t I plan to look into the Sonarr option. I love Plex so will continue to use either way. I prefer the option to scan the library on changes because the music library scan takes quite a while everytime.

Are you talking about auto scan on filesystem changes, or automatically as in every X mins? The latest should still work.

Sorry I should have clarified. I would prefer the Auto Scan on detected changes. Scan my library periodically works as intended.

Ok so as I stated before that is not supported by PMS on FreeBSD sadly and its unlikely it will anytime soon. It couldn’t have been working (update on filesystem changes) natively 3 weeks ago as this was never supported.

Mike knows better, of course; I’m just some random user. But I’ll vouch for his statement.

This was never a feature of Plex on FreeBSD. I’ve wanted it for years, and I’ve used a number of different methods and workarounds. But it’s never been a native thing in Plex on FreeBSD.

I’ve used Plex on FreeBSD directly on “real” FreeBSD, and as a FreeNAS plugin, and in a default jail on FreeNAS. None of those magically made it work.

I’ve used scripts that watched for top-level directory changes and triggered Plex, but didn’t scan as deeply. Things like Radarr and Sonarr can trigger Plex to scan sections quite effectively.

My server is terribly slow, but my media is local and on ZFS. Most of my directory metadata stays cached. I find I can rescan my libraries frequently in Plex without much impact.

Oh, and Mike mentioned fswatch.

That actually works really well for me. I don’t monitor every subdirectory and file, for all of the reasons he says.

But I do monitor my top-level media library folders. If a new directory is added, the parent library folder gets changed. I have it sleep for a bit, and then I trigger a scan for that library.

There’s some good tooling and discussion here:
https://forums.plex.tv/t/library-auto-updates-on-filesystem-change/

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.