[mythtvnz] Mythfrontend fails to connect to database

Stephen Worthington stephen_agent at jsw.gen.nz
Fri Jul 26 03:02:27 BST 2013


On Fri, 26 Jul 2013 08:42:42 +1200, you wrote:

>On Fri, 19 Jul 2013 13:44:48 +1200, Stephen Worthington  
><stephen_agent at jsw.gen.nz> wrote:
>
>> On Fri, 19 Jul 2013 07:58:07 +1200, you wrote:
>>
>>>
>>>
>>> Can I just say to everyone while we are vaguely on the subject, I make  
>>> it
>>> a policy when setting up mythtv to NEVER set things up to work through
>>> localhost. It is tempting to do so, but the moment you want to add an
>>> external frontend (and you will want to one day) you'll have a world of
>>> pain.
>>>
>>> Pick an IP address and hostname for the backend that you can live with,
>>> fix it and never change it. If you get a new backend, call it by the  
>>> same
>>> hostname as the old one and give it the same IP address.
>>>
>>> End of rant.
>>>
>>>
>>>
>>>
>>> It seems I wrote too soon.
>>> As with all intermittent problems,they do have the opportunity to mess
>>> with you and this is no exception.Yesterday after making Stephen's
>>> suggested changes the system started correctly over several reboots,then
>>> last night it reverted to the fault behaviour.
>>> Next I'll try Nick's suggestion of introducing a delay in the mysql
>>> startup script.
>>>
>>> Am I correct that the script to add the delay to would be mysql.conf?
>>>
>>> -Paul
>>
>> That would seem to be the right place.  Not having had to fiddle with
>> mysql's startup, I am not sure exactly what it requires.  But the
>> obvious thing to try first would be to add the same "net-device-up"
>> conditions that you are using for mythbackend.  If you have set up
>> mysql for using remote frontends, then you will have followed the
>> instructions for that and modified the /etc/mysql/my.cnf file to
>> comment out the "bind-address=127.0.0.1" line, so mysql will now need
>> to be able to bind all the network interfaces on startup.
>>
>> _______________________________________________
>
>I have been playing around with this problem since my last post here.
>Introducing a start delay to mysql to wait for the network did not help  
>,neither did adding a delay to mythbackend.conf.Nor did changing DataBase  
>server settings from localhost to the backend IP address.
>I don't know what caused it,but yesterday I was unable to shutdown the  
>system.It would hang at the Mythbuntu shutdown screen.
>Hitting ESC let me see the shutdown messages from the kernal?, the last  
>one was 'writing software time to hardware' then a cursor.I don't know if  
>this is relevant.
>I was in the process of diagnosing this today and the shutdown problem  
>came right.
>It did fail to shutdown several time today.There was nothing to see in the  
>logs.I guess logging services had already stopped.
>I did try the command: sudo /sbin/shutdown -P now and this failed to work.
>
>Anyway this has come right,apparently.
>I was thinking perhaps a delay to the frontend start might work.
>
>My question is: what initiates the front end start.There does not appear  
>to be a frontend equivalent to mythtv-backend.conf.
>
>-Paul

mythfrontend is started by the window manager when the default user
gets logged in.  The window manager is started by X when it starts up.
For Mythbuntu, the window manager is xfce4.  In xfce4, the autostart
settings are found on the menu at Applications -> Settings -> Session
and Startup -> Application Autostart.  I have never been entirely sure
about how xfce4 works - like X itself, the way all the settings are
stored seems to be mind-bogglingly complicated, forcing me to google
for answers when I need to adjust things.  But this is how I believe
that xfce4 startup is configured.

Each entry in the Application Autostart list seems to be an xfce4
desktop program file stored either in the user's local setup for xfce4
or in the global setup for xfce4.  I have yet to figure out how to get
the Application Autostart gui to tell me whether an item it has listed
is local to the user or global, but its Add button appears to only add
local user entries.

It seems that the startup files for all users are found at
/etc/xdg/autostart and for an individual user at
/home/<user>/.config/autostart.  In Mythtbuntu 12.04, in
/home/<user>/.config/autostart there should be a link called
mythtv.desktop which is linked to
/usr/share/applications/mythtv.desktop which is the actual file that
xfce4 uses to start mythfrontend.  Here is what mine looks like:

[Desktop Entry]
Name=MythTV Frontend
Comment=A frontend for all content on a mythtv-backend
GenericName=MythTV Viewer
Exec=mythfrontend --service
Type=Application
Encoding=UTF-8
Icon=mythtv
Categories=GNOME;Application;AudioVideo;Audio;Video
X-AppInstall-Package=mythtv


The situation is even more complicated by how Mythbuntu runs
mythfrontend.  The /usr/bin/mythfrontend file is actually a moderately
complex bash script that runs mythfrontend.real, and restarts it if it
crashes.

What I think you would need to do to add more delay to mythfrontend
starting would be to changed the
/usr/share/applications/mythtv.desktop file to run a bash script
instead of "mythfrontend --service", and in that script, do your delay
and then run "mythfrontend --service".

That might be a workaround that fixes your immediate problem, but I
suspect it is not the right way to fix things.  It would be better if
we could figure out why things are not ready in time on your system
and fix that.

On the subject of shutdown failures, I have occasionally suffered from
the same problem, and like you, had it go away again on its own.  The
only thing I can think of that might have been what made it go away
was to fully power off the PC so that even the standby power on the
motherboard was off and leave it for a couple of minutes for the
capacitors to discharge before restarting.  That completely resets all
the hardware and gets all devices to be coldstarted, including
reloading all their firmware.  If you have external devices such as
tuners or external hard drives with their own power packs, turn them
off too, then on again and let them power up fully before rebooting
the PC.



More information about the mythtvnz mailing list