Mediacenter auto restart when freezing

Hey there !

As I’m experiencing a few freeze of the mediacenter service, I was wandering if I can tweak the system to auto-restart mediacenter.service when it freezes ?
Maybe modifying Restart=always in “[Service]” in file /lib/systemd/system/mediacenter.service

Otherwise I was thinking of a script with cron scheduling like below :

until mediacenter; do
   echo 'mediacenter service has crashed with exit code $?. Restarting...' >&2
   sleep 1
done  

Any help would be much appreciated.

Thanks in advance

Some improvements to freezing have been made. This will be available soon and will likely resolve the problems you are experiencing. If not – it’s better to open a thread and discuss the freezing problem so we can solve things the correct way.

Ok thanks.

This would not work because when Kodi “freezes” it is still executing, it has not crashed. Therefore there is nothing for systemd to restart.

Also, the script that launches Kodi - /usr/bin/mediacenter already has a watchdog loop that will automatically restart Kodi if it crashes - this is what happens when you see Kodi crash with a sad face before restarting.

Thanks for the reply.
The problem is that I don’t see the sad face at all, the kodi GUI freeze and nothing happens, it get stuck like that. The only solution is restarting mediacenter.service through ssh.

As the rpi is running at my grand-mother’s place, and she actually does not know anything about ssh and computing, I was wandering if there’s any way of listening to the process then a find a way to detect if it has freeze (high memory consumption of kodi process or whatever) in order to auto-restart the mediacenter service.

By the way, when I type loggin as osmc systemctl status mediacenter, here’s the output :

  • mediacenter.service - media center application
    Loaded: loaded (/lib/systemd/system/mediacenter.service; enabled)
    Active: active (running) since Fri 2016-06-17 14:25:49 MUT; 6h ago
    Main PID: 472 (mediacenter)
    CGroup: /system.slice/mediacenter.service
    |-472 /bin/bash /usr/bin/mediacenter
    |-504 sudo -u osmc /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd
    `-505 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd

Seems there’s 2 instances of Kodi running. Is it ok ?

Thanks.

It’s not two instances, mine looks the same.

osmc@osmc:~/.kodi$ systemctl status mediacenter
* mediacenter.service - media center application
   Loaded: loaded (/lib/systemd/system/mediacenter.service; enabled)
   Active: active (running) since Mon 2016-06-13 13:29:45 EDT; 4 days ago
 Main PID: 374 (mediacenter)
   CGroup: /system.slice/mediacenter.service
           |-374 /bin/bash /usr/bin/mediacenter
           |-407 sudo -u osmc /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd
           `-413 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd

Ok thanks.