...and thanks for being a smartass
]]>Success! Not very sexy, but it works, I updated the wiki with a method to get mysqld AND mythtvbackend to work together with systemd.
https://wiki.archlinux.org/index.php/Sy … ces#mysqld
https://wiki.archlinux.org/index.php/Sy … ythbackend
I'm glad that it works for you. Anyway, since you already said yourself that it's "not very sexy", I'm gonna be a smartass and tell you why.
Type=simple
Not neccessary since it's the default.
PIDFile=/var/run/mysqld/mysqld.pid
This should only be neccessary for Type=forking , so it can be removed as well.
ExecStartPre=/usr/bin/mysqld-pre
Completely unneccessary as well, this is exactly what the tmpfiles.d/mysqld.conf file is for (that you removed from the wiki page). have a look at "man tmpfiles.d" .
ExecStart=/usr/bin/mysqld_safe --user=mysql
Are you sure that mysqld_safe is neccessary here? does mysqld not work? Because mysqld_safe seems to do stuff that systemd is supposed to do (restarting the service when it crashes etc, see "man mysqld_safe").
Also remove --user=mysql here and set User=mysql here. The fedora service file uses it as well so I assume this works.
Also let systemd handle the timeout, makes the -post script much shorter. This pid file stuff is is not neccessary in the script either.
#!/bin/sh
while true; do
response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
echo "$response" | grep -q "mysqld is alive" && break
sleep 1
done
[Unit]
Description=MySQL Server
[Service]
User=mysql
ExecStart=/usr/bin/mysqld
ExecStartPost=/usr/bin/mysqld-post
Restart=always
Timeout=30
[Install]
WantedBy=multi-user.target
This works fine on my setup, please test it on your system too and change the wiki accordingly.
]]>/etc/rc.d/oscam start
sleep 20
/etc/rc.d/sasc-ng start
sleep 5
/etc/rc.d/mythbackend start
sleep 5
/etc/rc.d/httpd start (for mythweb)
Then lxdm does it's thing
BTW #1: I find LDXE to be a good DE for a server as it doesn't seem to meddle with processes
BTW #2: There is a command to change lirc to use LIRC mode at the end of rc.local for the frontends or LIRC becomes flakey. I don't exact syntax out of my head.
https://wiki.archlinux.org/index.php/Sy … ces#mysqld
https://wiki.archlinux.org/index.php/Sy … ythbackend
*I don't know about that network.target - it might symlink to other daemons?
*Both MYTHCONFIDIR and HOME are dirs... am I missing something?
EDIT: I removed the trailing mythbackend.log from the first post so it just points to a dir.
$ ls -l /etc/conf.d/mythbackend
-rw-r--r-- 1 root root 1920 Apr 15 21:12 /etc/conf.d/mythbackend
$ ls -l /usr/share/mythtv/
total 228
drwxr-xr-x 2 root root 4096 Apr 18 22:12 backend-config
drwxr-xr-x 3 root root 4096 Apr 18 22:11 bindings
-rw-r--r-- 1 root root 7708 Apr 10 01:29 CDS_scpd.xml
-rw-r--r-- 1 root root 4852 Apr 10 01:29 CMGR_scpd.xml
drwxr-xr-x 8 root root 4096 Apr 18 22:12 contrib
-rw-r--r-- 1 root root 1741 Apr 10 01:29 devicemaster.xml
-rw-r--r-- 1 root root 840 Apr 10 01:29 deviceslave.xml
drwxr-xr-x 2 root root 4096 Apr 18 22:12 fonts
drwxr-xr-x 3 root root 4096 Apr 18 22:12 hardwareprofile
drwxr-xr-x 10 root root 4096 Apr 18 22:12 html
drwxr-xr-x 2 root root 4096 Apr 18 22:12 i18n
drwxr-xr-x 4 root root 4096 Apr 18 22:12 internetcontent
drwxr-xr-x 2 root root 4096 Apr 18 22:12 locales
-rw-r--r-- 1 root root 320 Apr 18 22:12 mc.sql
drwxr-xr-x 4 root root 4096 Apr 18 22:12 metadata
-rw-r--r-- 1 root root 1039 Apr 10 01:29 MFEXML_scpd.xml
-rw-r--r-- 1 root root 2599 Apr 10 01:29 MSRR_scpd.xml
-rw-r--r-- 1 root root 14781 Apr 10 01:29 MXML_scpd.xml
-rwxr-xr-x 1 root root 58750 Apr 10 01:29 mythconverg_backup.pl
-rwxr-xr-x 1 root root 68457 Apr 10 01:29 mythconverg_restore.pl
-rw-r--r-- 1 root root 1252 Apr 10 01:29 setup.xml
drwxr-xr-x 12 root root 4096 Apr 19 17:28 themes
So here is the fedora mysqld.service
[Unit]
Description=MySQL database server
After=syslog.target
After=network.target
[Service]
Type=forking
User=mysql
Group=mysql
ExecStartPre=/usr/libexec/mysqld-prepare-db-dir
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=/usr/bin/mysqld_safe --nowatch --basedir=/usr
ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
# We rely on systemd, not mysqld_safe, to restart mysqld if it dies
Restart=always
[Install]
WantedBy=multi-user.target
This is significantly different than the recommended arch version:
[Unit]
Description=MySQL Server
After=syslog.target network.target
[Service]
PIDFile=/var/run/mysqld/mysqld.pid
ExecStart=/usr/bin/mysqld --user=mysql --pid-file=/var/run/mysqld/mysqld.pid
ExecStop=/bin/kill -15 $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
Can someone with some experience with systemd propose a hybrid?
]]>@65kid - seems like Fedora should have their packages online like we do somewhere
They do.
]]>@65kid - you're using the fedora script? Can you post the output of :
$ pacman -Qo /usr/bin/my_print_defaults
yes, using the fedora script.
/usr/bin/my_print_defaults is owned by mysql 5.5.24-1
$ pacman -Qo /usr/bin/my_print_defaults
[Service]
...
ExecStartPost=/etc/systemd/system/mysql-wait.sh $MAINPID
these kind of crappy shell scripts are actually what systemd wants to get rid of, let's hope mysql upstream fixes this.
]]>$ cat ./usr/libexec/mysqld-wait-ready
#!/bin/sh
# This script waits for mysqld to be ready to accept connections
# (which can be many seconds or even minutes after launch, if there's
# a lot of crash-recovery work to do).
# Running this as ExecStartPost is useful so that services declared as
# "After mysqld" won't be started until the database is really ready.
# Service file passes us the daemon's PID
daemon_pid="$1"
# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
}
# Defaults here had better match what mysqld_safe will default to
get_mysql_option mysqld datadir "/var/lib/mysql"
datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$result"
# Wait for the server to come up or for the mysqld process to disappear
ret=0
while /bin/true; do
RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
mret=$?
if [ $mret -eq 0 ]; then
break
fi
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
# anything else suggests a configuration error
if [ $mret -ne 1 -a $mret -ne 11 ]; then
ret=1
break
fi
# "Access denied" also means the server is alive
echo "$RESPONSE" | grep -q "Access denied for user" && break
# Check process still exists
if ! /bin/kill -0 $daemon_pid 2>/dev/null; then
ret=1
break
fi
sleep 1
done
WTF: /usr/bin/my_print_defaults
Here is the Arch rc.d script... how to adapt this for systemd?
stat_busy "Starting MySQL Server"
[ ! -d /var/run/mysqld ] && install -d -g mysql -o mysql /var/run/mysqld &>/dev/null
if [ -z "$(getPID)" ]; then
/usr/bin/mysqld_safe --user=mysql &>/dev/null &
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
timeo=30
while [ $timeo -gt 0 ]; do
response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
echo "$response" | grep -q "mysqld is alive" && break
sleep 1
let timeo=${timeo}-1
done
if [ $timeo -eq 0 ]; then
stat_fail
exit 1
else
echo $(getPID) > /var/run/mysqld/mysqld.pid
add_daemon mysqld
stat_done
fi
fi
else
stat_fail
exit 1
fi
@65kid - seems like Fedora should have their packages online like we do somewhere. Just curiously, why use mysql at all for xbmc since it supports mysql-lite out-of-the-box?
I assume you mean sqlite?
I use MySQL because I have XBMC running on multiple machines and this way they all share the same database. I can even stop a video on one machine and continue it on another easily because XBMC writes the "stopped-at-timestamp" into the database.