[mythtv-users] mythbackend won't start during bootup on fc16

R. G. Newbury newbury at mandamus.org
Wed May 9 03:31:09 UTC 2012


On 05/08/2012 09:31 PM, Monkey Pet wrote:
>> From syslog, why is the behavior different running it from the cmdline?
>
> May  8 18:21:12 mythtv mythbackend[1442]: Starting mythbackend: [  OK  ]
> May  8 18:21:14 mythtv mythbackend[1442]: No UPnP backends found
> May  8 18:21:14 mythtv mythbackend[1442]: Would you like to configure the
> database connection now? [no]
> May  8 18:21:14 mythtv mythbackend[1442]: [console is not interactive,
> using default 'no']
> May  8 18:21:15 mythtv systemd[1]: mythbackend.service: main process
> exited, code=exited, status=130
> May  8 18:21:15 mythtv mythbackend[1806]: Stopping mythbackend: [FAILED]
> May  8 18:21:15 mythtv systemd[1]: Unit mythbackend.service entered failed
> state.
> May  8 18:26:07 mythtv mythbackend[2635]: Starting mythbackend: [  OK  ]
>
>
>
> On Tue, May 8, 2012 at 6:27 PM, Monkey Pet<monkeypet at gmail.com>  wrote:
>
>> I can't figure out why mythbackend isn't starting up on bootup.  It starts
>> up manually just fine.
>>
>> [root at mythtv fa]# cat /etc/fedora-release
>> Fedora release 16 (Verne)
>>
>> [root at mythtv fa]# runlevel
>> N 5
>>
>> [root at mythtv fa]# systemctl enable mythbackend.service
>> mythbackend.service is not a native service, redirecting to
>> /sbin/chkconfig.
>> Executing /sbin/chkconfig mythbackend on
>>
>> [root at mythtv fa]# chkconfig
>>
>> Note: This output shows SysV services only and does not include native
>>        systemd services. SysV configuration data might be overridden by
>> native
>>        systemd configuration.
>>
>> denyhosts       0:off 1:off 2:off 3:off 4:off 5:on 6:off
>> ipsec           0:off 1:off 2:off 3:off 4:off 5:off 6:off
>> iscsi           0:off 1:off 2:off 3:on 4:on 5:on 6:off
>> iscsid         0:off 1:off 2:off 3:on 4:on 5:on 6:off
>> jexec           0:on 1:on 2:on 3:on 4:on 5:on 6:on
>> livesys         0:off 1:off 2:off 3:on 4:on 5:on 6:off
>> livesys-late   0:off 1:off 2:off 3:on 4:on 5:on 6:off
>> mythbackend     0:off 1:off 2:on 3:on 4:on 5:on 6:off
>> netconsole     0:off 1:off 2:off 3:off 4:off 5:off 6:off
>> netfs           0:off 1:off 2:off 3:on 4:on 5:on 6:off
>> network         0:off 1:off 2:off 3:off 4:off 5:off 6:off
>> sandbox         0:off 1:off 2:off 3:off 4:off 5:off 6:off
>> zoneminder     0:off 1:off 2:on 3:on 4:on 5:on 6:off
>>
>> [root at mythtv fa]# /etc/init.d/mythbackend start
>> Starting mythbackend (via systemctl):                      [  OK  ]
>>
>> [root at mythtv fa]# service mythbackend status
>> mythbackend.service - SYSV: mythbackend.
>>    Loaded: loaded (/etc/rc.d/init.d/mythbackend)
>>    Active: active (running) since Tue, 08 May 2012 18:26:07 -0700; 32s ago
>>   Process: 2635 ExecStart=/etc/rc.d/init.d/mythbackend start (code=exited,
>> status=0/SUCCESS)
>> Main PID: 2640 (mythbackend)
>>    CGroup: name=systemd:/system/mythbackend.service
>>    └ 2640 /usr/bin/mythbackend --daemon --logpath /var/log/m...


If you are running Fedora 16, startup is properly done by systemd. There 
is a facility where systemd starts processes as if it were sysV but 
simulations are never quite the real thing. Systemd really really wants 
to see a proper xx.service file, and use that instead of faking it. And 
I suspect that the 'faking it' part is the problem.

Systemd is very particular about how things are set up and does not seem 
to create folders and files properly, especially /run/xxx. Also it seems 
to have problems with permissions: they must be correct.

I use the setup files below. Pre-start,sh does setup checks, as did/do 
certain scripts which mysqld.service runs when it starts. (Opposite to 
mysqld, it kills any running mythbackend process, on the assumption that 
it is locked up. All this makes sure that mythbackend.service sees the 
correct structures/owners/permissions. The xxx.service files are also 
very particular about the switches (simple/forking etc) used, and 
changing one can completely upset things. The available 'help' does not 
go into much detail. This was mainly trial and error. Lots of error.
HTH
Geoff


###################################################
#/lib/systemd/system/mythbackend.service
[Unit]
Description=MythTV backend service
# based on a template from RPMFusion
# and revised greatly

Wants=httpd.service
# for mythweb: not necessary so 'wants' not 'after'
After=network.target mysqld.service

[Service]
Type=forking
#PIDFile=/var/log/mythtv/backend.pid
#cannot use this not allowed in [Service]
# place everything in /var/log/mythtv
Environment=MYTHCONFDIR=/var/log/mythtv
Environment=HOME=/var/log/mythtv
Environment=MYTHBACKEND_USER=root
EnvironmentFile=/etc/sysconfig/mythbackend
User=mythtv
ExecStartPre=/usr/local/bin/pre-start.sh
# all on one line
ExecStart=/usr/local/bin/mythbackend --daemon --noupnp --loglevel crit 
--logpath /var/log/mythtv --nodblog --pidfile /var/log/mythtv /backend.pid


[Install]
WantedBy=multi-user.target


################################################
# /usr/local/bin/pre-start.sh
  #!/bin/bash

# Sanity check on existence of required user
# Needed after bare-metal install and worth checking otherwise
# DEFAULT user and password: fix mysql if changed!
# should match config.xml (and mysql.txt)

USERNAME="mythtv"
PASSWORD="mythtv"

# Non-usual home for mythtv user
export HOME=/var/log/mythtv
export MYTHTV_HOME=/var/log/mythtv

# UTF encoding needed by myth
export LC_ALL=en_US.UTF-8

# Check for user, create if missing, create HOME too
RESULT=""
# if user exists, will be in /etc/passwd file
RESULT=`grep "$USERNAME" /etc/passwd`;
if [ "$RESULT" == ""  ]; then
      #  echo "Mythtv user not found, user account will be created"
      useradd -m -d "$HOME" -G mysql -p "$PASSWORD" -U "$USERNAME" 2&>1;
   else
      echo ""    # acts as a NOP for the else branch
      #  echo "Mythtv user found, no action taken"  # testing only
fi

# Sanity check on required folders
mkdir -p -m 755 /var/log/mythtv
chown -hR mythtv:mythtv /var/log/mythtv
# since creating folders in /var/run fails,
# use /var/log for pidfile instead on
# call to mythbackend cmd line



More information about the mythtv-users mailing list