Native filesystem monitoring for libraries updates
these days I had some time to develop an add-on for Serviio in order to use native file monitoring features to trigger library updates. This should then allows any HDD with resources monitored by a Serviio instance to correctly go on sleep when in idle .
The add-on requires at least a Java 7 runtime, and it should works on any O.S. By far, it has been tested it on:
- Windows 7 - 64bit
- Embedded Linux - Kernel 2.6.31.8 - ARMv5 (NAS Zyxel NSA310)
Actually, the add-on is just a jar to add to the Serviio's classpath, and it works using an alternative main Java entry class which, in turn, starts Serviio and, immediately after, starts its own monitoring feature for libraries configured inside Serviio.
Once started, it will trigger a Serviio full libraries scan after 5 seconds since the last filesystem change detected on any of the monitored directory (the 5 seconds delay is needed to avoid to request multiple consecutive scans when multiple files/directories are added/changed/removed). It can also detect long-copying operations, waiting the copy completion before trigger the library update.
The add-on is also capable to detect Serviio library configuration changes, in order to update directories being monitored. However, the configuration change monitoring is quite hackish, so it could not work on Serviio versions other then 1.4.1.2.
If ZIP give me the permission, I will be glad to attach needed files (released under Apache License 2.0) and installation instructions, creating also a github repository for patches and contributions.
========= INSTALL INSTRUCTIONS =========
- Disable Serviio automatic library update
- Stop Serviio server
- Download the jar add-on from https://www.dropbox.com/s/zewom1tnuql1q ... -1.0.0.jar
- Put the add-on jar into "<SERVIIO_PATH>\lib" directory
- Edit "<SERVIIO_PATH>\bin\serviio.bat" (Windows) or "<SERVIIO_PATH>/bin/serviio.sh" (Linux) and change every occurrence of org.serviio.MediaServer to com.lukakama.serviio.watchservice.WatchServiceMainWrapper
- ONLY ON LINUX - Edit any Lunix daemon script and change every occurrence of org.serviio.MediaServer to com.lukakama.serviio.watchservice.WatchServiceMainWrapper if any
- Start Serviio server
Source code on GitHub: https://github.com/lukakama/serviio-watch-service