OSMC MYSQL Startup problem

Hi guys, im using wifi to connect and it is working ok.

Only issue i have is when the pi starts, it does not connect for a while and so it cant connect tot he mysql database in time. If i goto power and hit exit and osmc reboots, it then works fine and shows my libraries etc.

Is there a way to make kodi refresh in a sense once wifi connects at a later stage?

thankyou sir.!!

enjoy!

This is an issue with Debian’s init-script for mysql-server. It would be nice to move forward to a systemd way of starting/stop services like mysql-server.

If kodi waits for network-startup to finish, it has no effect on whether or not mysql-server is started up properly. At the moment, I have to restart mysql-server after every reboot, as it consistently fails to start up properly!

Take a look at the following bug-report/discussion for an idea of what I mean.

EDIT: I apologize, as I assumed this thread was specific to OSMC on raspberry pi2, which is built on Debian Linux.

What you’re talking about is a completely separate issue to the original poster.

He has his mysql sever running on another machine, thus OSMC must wait for the wifi connection to come up before launching Kodi. This is achieved by the wait for network option in the networking GUI. (which didn’t exist at the time of the original post)

What you are talking about is waiting for a locally running mysql server to finish starting before Kodi is launched. This is done differently.

Even though mysql may be a legacy init script (I haven’t looked) you should still be able to use an After clause in the mediacenter service to make it wait for mysql to start. Can you try this for me:

Create a new file here:

/etc/systemd/system/mediacenter.service.d/local.conf

In this file put only these lines:

[Unit]
After = mysql-server.service

The after line should obviously match the service name if it is a systemd service, however if it is a legacy init script service, find the service name and append .service on the end. (Please let me know what the service name is, if I don’t get time to check myself)

Please try this and let me know if it works because if it does we are talking about adding an After dependency into the standard mediacenter service unit.

This works because if the mysql service is disabled or does not exist it is ignored and does not delay Kodi launch, but if the service is installed and enabled it would automatically delay Kodi until mysql loads without any manual user configuration.

I had the same problem and therefore i’m bringing this thread up again.
Fortunately the way dbmandrake describes seem to work. I just had to change the service name from “mysql-server” to just “mysql”.
With 4 or 5 reboots now i didn’t have the problem of the missing connection to the locally installed mysql database on my pi2.
Thx for the help!

If someone else could please confirm this so the developer can put this in one of the next updates.

How did you install mysql ? Just through apt-get install mysql ?

On my system, the mysql service (a legacy /etc/init.d/ service) is just called mysql. Therefore the line After = mysql.service, which is what we currently have in the mediacenter service is correct:

So I’m curious to know why your service was called mysql-server and not mysql. We can easily add mysql-server.service to the list as well, if some methods of installing mysql result in this service name. It does no harm to list a service that does not exist in an After line, it only has any effect if the service does exist and is enabled.

Yes, i installed it that way.

You misunderstood me, i was referring to your post from may where YOU wrote “mysql-server”.

Anyway, before i created the directory “mediacenter.service.d” in the given pathand the local.conf itself (as given with your posting from may) i had the problem after about 4 of 5 restarts. Both the directory and the file didn’t exist beforehand. So the general setting in the current service didn’t seem to work for me.

Or do i get something completely wrong? :slight_smile:
In this case sorry. I’m not native english.

Can you post the exact local.conf you used and a copy of your /lib/systemd/system/mediacenter.service ?

If your mysql service is called ‘mysql’ (or ‘mysql.service’) then it should work correctly already, so I’d like to understand why it is not.

Yes of course. But it’s gonna take some hours as i’m still at work.

Btw, big thx for the efforts of you and the others for this great project. Without any knowledge of raspberries and the whole unix-stuff i discovered this world six months ago. Now after this time i’m already running 4 devices and i’m almost happy. Especially since i noob managed to get the squeezebox stuff running since last werkend, giving me sync-audio playback in all rooms without loosing the raspbmc/osmc stuff.

Damn, although it was working for the past three days now my initial problem is back. No Movie, TV-Show and Music library after reboot.

The /lib/systemd/system/mediacenter.service shows:


[Unit]
Description = media center application
After = remote-fs.target network-online.target mysql.service
Wants = network-online.target

[Service]
Type = simple
TimeoutStopSec = 20
ExecStartPre = /bin/udevadm trigger
ExecStart = /usr/bin/mediacenter
ExecStopPost = /usr/bin/mediacenter stop
Restart = on-abort

[Install]
WantedBy = multi-user.target


my local.conf:


[Unit]
After = mysql.service


So everything is looking right.

I’m gonna delete the (as I know now) unnecessary local.conf and dig a little deeper in the logs.
If I find something or can’t sort things out by yself I’m gonna start a new thread as here it is offtopic.

Anyway, big thx for your help and efforts!