# Do not edit this file, it will be replaced on update
# If you need to make modifications to this unit file first make a copy in
# /etc/systemd/system

# This file is part of the packaging of MythTV
#
# MythTV is free software; view http://www.mythtv.org
# for more information.
#
# It is sometimes necessary to wait for a capture
# device to finish (hot)plug initialization before
# the backend starts.  If this is necessary,
# create a Wants and After entry for all the capture
# devices that one wishes to wait to be created
# before the backend starts using the systemd
# device name mangling names (/dev/some/thing turns
# into dev-some-thing.device).  These normally should
# be udev persistent filename rules to avoid confusion.
# See the MythTV wiki for udev persistent filename
# discussions found at:
# http://www.mythtv.org/wiki/Device_Filenames_and_udev
#
# In order to insure that systemd will create a
# device unit for the capture device, one must
# insure that udev will have the tag "systemd"
# (i.e. add TAG+="systemd" to the udev rule).
#
# The MythTV package ships with a default udev
# rule file located in: /lib/udev/rules.d/99-mythbackend.rules

[Unit]
Description=MythTV backend service
After=network-online.target mariadb.service mysqld.service time-sync.target
# Uncomment the following line if you will be using the mythweb plugin on the
# same system as mythbackend.
#Wants=httpd.service

[Service]
# Type=simple is recommended. If using Type=forking you will need to specify a
# pidfile so systemd knows how to find the forked process PID, otherwise it
# presumes that the process being started will be the remaining process.
#Type=forking
Type=simple

# Default setting assumes a system wide install. Otherwise it should be set to 
# the folder containing the .mythtv subfolder containing the config.xml file
Environment=MYTHCONFDIR=/etc/mythtv

# systemd changes execution from the calling user (possibly root) to this user
# if you have permissions problems or obscure errors try logging in as mythtv
User=mythtv

# Uncomment one of the following...
# Use sysloging rather than separate logging:
#ExecStart=/usr/bin/mythbackend --syslog local7
# If Type=forking is set you must specify the --daemon and --pidfile options:
#ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv --loglevel crit --pidfile /run/mythbackend.pid
# Default setting for Type=simple.
ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv

# Whether systemd will continue over-watch and restart on any halt
#Restart=always

# MariaDB seems to have a systemd related bug and tells systemd that it is
# ready to accept connections before it really is. If you have this problem
# try uncommenting the following lines:
# Restart=on-failure
# StartLimitBurst=5
# StartLimitInterval=1

[Install]
WantedBy=multi-user.target
