Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 498962 - dev-db/mysql is missing a systemd service-file
Summary: dev-db/mysql is missing a systemd service-file
Status: RESOLVED DUPLICATE of bug 466084
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-22 21:01 UTC by Stefan G. Weichinger
Modified: 2014-01-23 02:22 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan G. Weichinger 2014-01-22 21:01:40 UTC
As far as I see none of the ebuilds for dev-db/mysql (in portage) brings a service file for running mysqld with the systemd-init-system.

I suggest to have one added ...

I run one for months now, copied and modified from arch linux ... today I modified it to also wait for mysqld to be really up and ready.

If other services depend on mysqld.service it is important to not only have mysqld started but also check if it is ready to serve requests. The lack of this lead to problems with mythtv here after a reboot, for example.

-

I found service-files doing this:

https://bbs.archlinux.org/viewtopic.php?pid=1100107

https://github.com/remicollet/remirepo/blob/master/mysql55/mysqld.service

Both run a check-script as ExecStartPost.

I adapted the script from the first link and tested successfully.

# cat /etc/systemd/system/mysqld.service 
[Unit]
Description=mySQL Server
After=network.target

[Service]
ExecStart=/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf
ExecStartPost=/usr/local/bin/mysqld-post
ExecStop=/bin/kill -15 $MAINPID
Restart=always
Timeout=30

[Install]
WantedBy=multi-user.target


# cat /usr/local/bin/mysqld-post
#!/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


While this might not be the most elegant solution ... it just works for now.
Please consider adding a service-unit for mysql soon ...
Comment 1 Brian Evans (RETIRED) gentoo-dev 2014-01-22 21:05:20 UTC
A systemd unit exists in mysql-init-scripts-2.0_pre1-r6 which is stable on all arches
Comment 2 Stefan G. Weichinger 2014-01-22 21:08:49 UTC
(In reply to Brian Evans from comment #1)
> A systemd unit exists in mysql-init-scripts-2.0_pre1-r6 which is stable on
> all arches


oops! how embarrassing ... sorry for the noise.

looks as if it does everything needed ... and I always "masked" that unit with my selfmade file in /etc/systemd/system (seems as if mysql-init-scripts came later than my own file).

will test asap.

thanks
Comment 3 Alex Xu (Hello71) 2014-01-23 02:22:06 UTC
*mysql-init-scripts-2.0_pre1-r4 (03 Sep 2013)

  03 Sep 2013; Pacho Ramos <pacho@gentoo.org> +files/mysql.conf,
  +files/mysqld-prepare-db-dir, +files/mysqld-wait-ready, +files/mysqld.service,
  +files/mysqld_at.service, +mysql-init-scripts-2.0_pre1-r4.ebuild:
  Add systemd support (#466084)
Comment 4 Alex Xu (Hello71) 2014-01-23 02:22:21 UTC

*** This bug has been marked as a duplicate of bug 466084 ***