Re: mythbackend fails to start on boot; mysqld not ready
Chris Schanzle <[email protected]> Sat, 19 May 2012 08:30:14 -0400
| Newsgroups | gmane.linux.redhat.rpm.atrpms.devel |
|---|---|
| Message-ID | <[email protected]> |
On 05/17/2012 02:35 PM, George Galt wrote: > On Thu, May 17, 2012 at 6:39 AM, Brian Long<[email protected]> wrote: >> On Wed, May 16, 2012 at 11:00 PM, Chris Schanzle<[email protected]> wrote: >>> On 05/11/2012 11:38 AM, George Galt wrote: >>>> On Thu, Mar 29, 2012 at 8:42 AM, Chris Schanzle<[email protected]> >>>> wrote: >>>>> I would say about 25% of the time, mythbackend doesn't start on my >>>>> Fedora 16 >>>>> box on reboot. From the logs, it appears the local mysqld is not ready >>>>> to >>>>> accept connections. Unfortunately, it doesn't try to reconnect and the >>>>> result is missed recordings and a non-functional frontend. Restarting >>>>> mythbackend (service mythbackend restart) is the band-aid. >>>>> >>>>> Is there some improvement we can make to the initscript to ensure we can >>>>> talk to the sql server? I realize it might not be local on the box, so >>>>> we >>>>> can't just depend on the mysqld service. >>>>> >>>>> Note mysqld is a systemd service while mythbackend is a SysV service >>>>> (init.d >>>>> script). >>>>> >>>>> I'd take a stab at a fix, but would appreciate any guidance on the best >>>>> direction to head. >>>>> >>>>> Thanks! >>>>> >>>>> _______________________________________________ >>>>> atrpms-devel mailing list >>>>> [email protected] >>>>> http://lists.atrpms.net/mailman/listinfo/atrpms-devel >>>> >>>> Chris: >>>> >>>> Any luck on developing something that works here? I've noticed others >>>> are also having this issue and I'll probably take a look at it this >>>> weekend, but if you've made a headstart, please let me know. >>> >>> >>> I poked at it back in April but a mythtv update overwrote my mods, didn't >>> get any response, so I presumed it was just me. My mysqldb is quite large >>> (/var/lib/mysql/mythconverge = 222MB) so I can imagine MySQL might take a >>> few seconds to become ready. >>> >>> Putting a few more thoughts into it, I don't think this could/should be >>> fixed with initscripts, but rather is a bug in mythbackend which should >>> attempt to connect to the configured db until success, not just fail once >>> and fall over. >>> >>> From /var/log/boot.log, MySQL is starting before the mythbackend SYSV >>> script, so that's good. >>> >>> At this point, I'd take hack of a 'sleep 10' delay to the start() section >>> of /etc/init.d/mythbackend and run with it until a real fix is implemented. >>> :-) >>> >>> Chris >> >> There was a recent thread on mythtv-users (OP George Galt) where they >> "fixed" the mythbackend systemd start script. The RPMforge developer was >> going back-and-forth with some other folks about how to write the systemd >> file such that mythbackend would start properly. Last I saw, they had a >> final version worked out. Maybe AtRPMS could integrate the same systemd >> file since init is gone in Fedora 16. >> >> http://www.gossamer-threads.com/lists/mythtv/users/517350 >> >> /Brian/ > One thing to be aware of with that script is that it runs the backend > as the "mythtv" user. You may need to change the username to whatever > user is on your system, but also, you have to make sure that you > properly permission the appropriate directories. I believe they are: > /var/log/mythtv/ > /var/lib/mythtv/ > and whatever directories you use to store your videos and recordings in > > Also, make sure you include the user that your run the backend as (in > my case "mythtv") in the "audio" and "video" groups. The commands > are: > usermod -a -G audio mythtv > usermod -a -G video mythtv > > George Most excellent, working very nicely here; 5 or 6 reboots and mythbackend started every time (though firewire control of my motorola/verizon box worked 50%, that's not unusual). A few notes: turn off/disable init.d script before copying the systemd script into place, otherwise systemd steps in and ignores the init.d script. chkconfig mythbackend stop chkconfig mythbackend off echo 'd /var/run/mythtv 0755 mythtv mythtv -' > /etc/tmpfiles.d/mythbackend.conf # mythbackend *was* starting as root since my transition to Fedora 16. # make sure these are owned by the mythtv user, plus all recordings directories $ ls -ld /var/l*/mythtv /video2 /2012 /local/video drwxr-xr-x. 11 mythtv mythtv 4096 Apr 30 08:37 /var/lib/mythtv drwxr-xr-x. 2 mythtv mythtv 73728 May 18 22:07 /var/log/mythtv # did not test not adding to audio/video groups usermod -a -G audio mythtv usermod -a -G video mythtv cat > /lib/systemd/system/mythbackend.service << \EOF ################################################### # file located at /lib/systemd/system/mythbackend.service # use "systemctl enable mythtbackend.service to load # based on a template from RPMFusion and R.G. Newbury from this thread: # http://www.gossamer-threads.com/lists/mythtv/users/516650?search_string=mythbackend.service%20;#516650 [Unit] Description=MythTV backend service After=network.target mysqld.service # for mythweb: not necessary so 'wants' not 'after' Wants=httpd.service [Service] Type=simple Environment=MYTHTV_HOME=/var/lib/mythtv Environment=MYTHCONFDIR=/var/lib/mythtv Environment=HOME=/var/lib/mythtv # NOTE: using the "mythtv" user, NOT root. User=mythtv # NOTE: if you have other switches you want, insert them below. This is set to use log files in # /var/log/mythtv. Make sure that the location of the HOME/MYTHCONFIG files, logs and the pid file # are writeable by the user designated above. ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv [Install] WantedBy=multi-user.target EOF systemctl enable mythtbackend.service # test before rebooting -- check logs. install -d --owner mythtv --mode 755 /var/run/mythtv systemctl start mythbackend.service reboot/reboot/reboot/reboot! Hmm, /run/mythtv is empty. Makes me wonder if the tmpfiles.d addition is required. Big step forward...Thanks!