SQL server in a docker container...

  • I installed the docker-addon and from the LinuxServer.io's docker addon repo the MariaDB image. Really great thing!
    In advancedsettings.xml I pointed to the SQL database for video. Now I have the problem, that when libreelec and Kodi start, it can not access the SQL Server, because the container takes some seconds longer to start up. I activated already the "wait for network (10sec)" but this does not help.
    When I ssh into libreelec and "systemctl restart Kodi.service", it works fine because the SQL Server is then up and running.

    Can anybody explain, how the start-up of the different software's work and where I have to put in a few seconds of wait ??

    Thanks,
    /BJ


  • OK, I tried with "sleep 10" in autostart.sh, works but not so nice.
    I will give "/storage/.config/systemd/kodi.target.wants" a try....


    Thanks for testing this.

    I used the mariadb addon only for other services and not for the kodi library itself.

    One possible fix is editing the mariadb addon's systemd service file and adding "Before=kodi.service" to make sure mariadb is up before kodi. Could you test that and let me know? If it works, I'll update the addon.

    You can find the service file under /storage/.kodi/addons/docker.linuxserver.mariadb/systemd/

  • That didn't help, I tried also by linking the docker.linuxserver.mariadb.service into .../kodi.target.wants, no success. I still need the "sleep 10" in autostart.sh... I guess that it's not enough that the service starts before Kodi, it also takes some time till the database is initialized and ready to answer requests. I see that tvheadend and others are linked into the dir .../kodi.target.wants (?) but when Kodi is up I see the message "tvheadend is starting up" with spinning wheel, so seems that Kodi is explicitelx waiting for the pvr service..

    Any recommendations ?

  • Figured out a way to make the kodi service wait for mariadb to go up. Just need to package it up in the most optimum way so that it only causes a delay for folks who use it for their kodi library
    [hr]
    Can you test installing this from zip? docker.linuxserver.mariadb-1.0.4.zip

    It should update your existing addon. Then go into the addon settings and turn the last setting on

    I tested it both ways and seems to work. Once you confirm, I'll push it to the repo

    Edited once, last by aptalca (March 20, 2017 at 12:18 AM).


  • Yes, I installed it and after many (re)boots (cold and warm) I would say it is ok 4 out of 5 times.
    Any log wanted?

    Thanks for your efforts,
    BJ


    So, if you could get logs from that 1 out of 5 times, that would be great.

    I hardcoded a 10 second pause between the container creation/start and kodi service coming up. In my case, it takes about 4 seconds for mysql to be up and running after container start. Perhaps in some cases it may take longer?

    For the logs you can try the following three:
    journalctl -u docker.linuxserver.mariadb
    journalctl -u kodi
    And of course checking the kodi log

    I'm mostly interested in the timestamps comparing the time for the line with s6-init from the mariadb one and the kodi service start (and when kodi tries to connect to the database)


  • I hardcoded a 10 second pause between the container creation/start and kodi service coming up. In my case, it takes about 4 seconds for mysql to be up and running after container start.

    I have done that a different way with my lemp container :

    Code
    while [ ! $(docker exec lemp ls /run/mysqld/mysqld.sock 2>/dev/null) ]; do sleep 0.5; done

    You may have to adapt it to the location of the socket in your container.

  • aptalca
    I guess that this is what we are looking for :

    journalctl -u docker.linuxserver.mariadb :
    Mar 21 09:50:27 LibreELECintel systemd[1]: Starting docker.linuxserver.mariadb container...
    Mar 21 09:50:30 LibreELECintel sh[814]: docker.linuxserver.mariadb
    ....
    Mar 21 09:50:37 LibreELECintel systemd[1]: Started docker.linuxserver.mariadb container.
    Mar 21 09:50:37 LibreELECintel sh[814]: 170321 09:50:37 mysqld_safe Logging to syslog.

    journalctl -u kodi :
    Mar 21 09:50:38 LibreELECintel systemd[1]: Starting Kodi Media Center...Mar 21 09:50:38 LibreELECintel systemd[1]: Started Kodi Media Center....

    kodi.log :
    09:50:45.929 T:139892836030208 ERROR: Unable to open database: MyVideos107 [2003](Can't connect to MySQL server on 'libreelecintel' (111))

    Edited once, last by berniejonnie (March 21, 2017 at 9:10 AM).

  • I have done that a different way with my lemp container :

    Code
    while [ ! $(docker exec lemp ls /run/mysqld/mysqld.sock 2>/dev/null) ]; do sleep 0.5; done

    You may have to adapt it to the location of the socket in your container.

    That is an excellent suggestion. Thanks
    [hr]

    It seems your issue is different (network related). In this case, kodi attempted to connect to the library 8 seconds after mysql went up. It should have connected just fine.

    Do you have the option to wait for network before starting kodi turned on in libreelec settings? Also you can try to use the IP address for mysql rather than the hostname in advancedsettings.xml

    Edited once, last by aptalca (March 21, 2017 at 2:58 PM).

  • Yes, right. I changed to the IP address and now Kodi opens the sql-db 4 seconds after the sql-container started.

    Thanks !!

    P.S. Does somebody know how I can make disappear all the docker relates status messages from the boot- and shutdown-screen ? That stopped already when 8.0 approached the release and now it is partly back...