mysql55: Port to systemd

Not tested.  Seriously tempted to delete mysql55.  See issue #47.
This commit is contained in:
Eelco Dolstra 2012-12-18 13:43:01 +01:00
parent 75c67b0194
commit ab18c03685

View file

@ -84,6 +84,7 @@ in
description = "A file containing SQL statements to be executed on the first startup. Can be used for granting certain permissions on the database";
};
# FIXME: remove this option; it's a really bad idea.
rootPassword = mkOption {
default = null;
description = "Path to a file containing the root password, modified on the first startup. Not specifying a root password will leave the root password empty.";
@ -133,10 +134,12 @@ in
environment.systemPackages = [mysql];
jobs.mysql =
{ description = "MySQL server";
boot.systemd.services.mysql =
{ description = "MySQL Server";
startOn = "filesystem";
wantedBy = [ "multi-user.target" ];
unitConfig.RequiresMountsFor = "${cfg.dataDir}";
preStart =
''
@ -149,9 +152,12 @@ in
mkdir -m 0700 -p ${cfg.pidDir}
chown -R ${cfg.user} ${cfg.pidDir}
'';
${mysql}/bin/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions} &
serviceConfig.ExecStart = "${mysql}/bin/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
postStart =
''
# Wait until the MySQL server is available for use
count=0
while [ ! -e /tmp/mysql.sock ]
@ -216,14 +222,10 @@ in
rm /tmp/mysql_init
fi
'';
''; # */
postStop = "${mysql}/bin/mysqladmin ${optionalString (cfg.rootPassword != null) "--user=root --password=\"$(cat ${cfg.rootPassword})\""} shutdown";
# !!! Need a postStart script to wait until mysqld is ready to
# accept connections.
extraConfig = "kill timeout 60";
serviceConfig.ExecStop =
"${mysql}/bin/mysqladmin ${optionalString (cfg.rootPassword != null) "--user=root --password=\"$(cat ${cfg.rootPassword})\""} shutdown";
};
};