Moode Forum
[PROBLEM] DLNA database needs to be rebuilt every boot. - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [PROBLEM] DLNA database needs to be rebuilt every boot. (/showthread.php?tid=4837)



DLNA database needs to be rebuilt every boot. - DRONE7 - 04-16-2022

Using a MoOde RPi as a DLNA server but have to rebuild the miniDLNA database every boot otherwise the clients (upplay>gmediarender) fail to find it.

Expected behaviour would be the database would be stored between boots or,  if the DLNA renderer is set on then at the least the database should be rebuilt automatically at boot.

Having to manually set the rebuild each time is not useful.


RE: DLNA database needs to be rebuilt every boot. - Tim Curtis - 04-16-2022

I don't use it but I recall that miniDLNA sometimes would automatically rebuild after reboot. It may have to do with the fact that it's started before NAS source is mounted during moOde startup. Maybe it needs to have the source mounted before it starts??

One test would be to turn it off in UI before rebooting then turn on afterwords and see if it does an automatic rebuild.


RE: DLNA database needs to be rebuilt every boot. - Tim Curtis - 04-16-2022

Actually what I proposed won't work because when miniDLNA is stopped in UI its cache is also cleared which includes its database.

/var/cache/minidlna/


RE: DLNA database needs to be rebuilt every boot. - DRONE7 - 04-18-2022

Quote:It may have to do with the fact that it's started before NAS source is mounted during moOde startup. Maybe it needs to have the source mounted before it starts??

when miniDLNA is stopped in UI its cache is also cleared which includes its database.

Yes..that describes the problem perfectly... cache is not kept between boots and miniDLNA starts ahead of the NAS in boot order.

Is there any downside to keeping the cache ? or linking its update to the library update ?

Is there a code line that could be commented that would cancel the cache clearing..? just to try and see after a cold start if the clients would find the server.


RE: DLNA database needs to be rebuilt every boot. - TheOldPresbyope - 04-18-2022

(04-18-2022, 03:34 AM)DRONE7 Wrote:
Quote:It may have to do with the fact that it's started before NAS source is mounted during moOde startup. Maybe it needs to have the source mounted before it starts??

when miniDLNA is stopped in UI its cache is also cleared which includes its database.

Yes..that describes the problem perfectly... cache is not kept between boots and miniDLNA starts ahead of the NAS in boot order.

Is there any downside to keeping the cache ? or linking its update to the library update ?

Is there a code line that could be commented  that would cancel the cache clearing..? just to try and see after a cold start if the clients would find the server.


"Is there any downside to keeping the cache ?" Dunno but...

A quick grep of 'minidlna' on the contents or /var/www flagged worker.php as the likely culprit. For clarity I've repeated the grep on just it:

Code:
pi@m8pi3a:/var/www/command $ grep -n minidlna worker.php
2067:        case 'minidlna':
2069:            sysCmd('systemctl stop minidlna');
2074:                syscmd('rm -rf /var/cache/minidlna/* > /dev/null');
2078:            sysCmd('systemctl stop minidlna');
2079:            syscmd('rm -rf /var/cache/minidlna/* > /dev/null');

This is PHP code. You can comment out lines 2074 and 2079 by prepending the double solidus (//). 

Good luck!

Regards,
Kent


RE: DLNA database needs to be rebuilt every boot. - Tim Curtis - 04-18-2022

My earlier post may have been a bit confusing but miniDLNA cache is only cleared by moOde as follows:

1. Turning it off in the UI
2. Clicking "REBUILD" miniDLNA database in UI

Otherwise moOde doesn't touch the DLNA cache and so if miniDLNA is left On the cache should be left alone after reboot. If it's not then it must be some code in monoDLNA itself thats automatically rebuilding the database when it starts after a reboot. Why I don't know.


RE: DLNA database needs to be rebuilt every boot. - Tim Curtis - 04-18-2022

I moved the code block in worker.php that does the source mounts to a position before the code block that starts the renderers and UPnP/DLNA services and this time after a reboot miniDLNA did not automatically do a database rebuild.

I'll include the change in upcoming r810 release but if you want to try it do the following:

1. Edit /var/www/command/worker.php
2. Move the code block below

Code:
//
workerLog('worker: --');
workerLog('worker: -- Music sources');
workerLog('worker: --');
//

// List USB sources
$usbdrives = sysCmd('ls /media');
if ($usbdrives[0] == '') {
    workerLog('worker: USB sources (none attached)');
}
else {
    foreach ($usbdrives as $usbdrive) {
        workerLog('worker: USB source ' . '(' . $usbdrive . ')');
    }
}

// Mount NAS and UPnP sources
$result = sourceMount('mountall');
workerLog('worker: NAS and UPnP sources (' . $result . ')');


3. to just above where Feature availability section starts, like below

Code:
// Ignore CUE files
setCuefilesIgnore($_SESSION['cuefiles_ignore']);
workerLog('worker: MPD ignore CUE files (' . ($_SESSION['cuefiles_ignore'] == '1' ? 'yes' : 'no') . ')');

//
workerLog('worker: --');
workerLog('worker: -- Music sources');
workerLog('worker: --');
//

// List USB sources
$usbdrives = sysCmd('ls /media');
if ($usbdrives[0] == '') {
    workerLog('worker: USB sources (none attached)');
}
else {
    foreach ($usbdrives as $usbdrive) {
        workerLog('worker: USB source ' . '(' . $usbdrive . ')');
    }
}

// Mount NAS and UPnP sources
$result = sourceMount('mountall');
workerLog('worker: NAS and UPnP sources (' . $result . ')');

//
workerLog('worker: --');
workerLog('worker: -- Feature availability');
workerLog('worker: --');
//



RE: DLNA database needs to be rebuilt every boot. - TheOldPresbyope - 04-18-2022

i note that /etc/init.d/minidlna includes '-r' (for rescan) as a flag in the startup of minidlnad. 

In the comment header of the same file it makes the point that network, local filesystem and remote filesystem are all required for start.

Just sayin'

Regards,
Kent


RE: DLNA database needs to be rebuilt every boot. - Tim Curtis - 04-18-2022

miniDLNA is started by /lib/systemd/system/minidlna.service but I see that it also specifies -r (lowercase)

The help indicates that -r (rescan) is different than -R (rebuild)

Code:
pi@moode:~ $ minidlnad --help
[2022/04/18 10:13:48] minidlna.c:971: error: Usage:
       minidlnad [-d] [-v] [-f config_file]
               [-a listening_ip] [-i network_interface]
               [-u uid_to_run_as] [-g group_to_run_as]
               [-p port] [-s serial] [-m model_number]
               [-t notify_interval] [-P pid_filename]
               [-u uid_to_run_as]
               [-w url] [-r] [-R] [-L] [-S] [-V] [-h]

Notes:
       Notify interval is in seconds. Default is 895 seconds.
       Default pid file is /run/minidlna/minidlna.pid.
       With -d minidlna will run in debug mode (not daemonize).
       -w sets the presentation url. Default is http address on port 80
       -v enables verbose output
       -h displays this text
       -r forces a rescan
       -R forces a rebuild
       -L do not create playlists
       -S changes behaviour for systemd/launchd
       -V print the version number
pi@moode:~ $