mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-06 12:33:51 +00:00
* mysql: merged the mysql expression in the services tree.
* mysql: run under a separate user ("mysql"), not under "nobody". * mysql: put the PID under /var/run. svn path=/nixos/trunk/; revision=12189
This commit is contained in:
parent
314ab9774f
commit
90acbf9509
|
@ -1933,7 +1933,7 @@
|
|||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "nobody";
|
||||
default = "mysql";
|
||||
description = "User account under which MySQL runs";
|
||||
};
|
||||
|
||||
|
@ -1947,8 +1947,8 @@
|
|||
description = "Location of the MySQL error logfile";
|
||||
};
|
||||
|
||||
pidFile = mkOption {
|
||||
default = "/var/mysql/mysql.pid";
|
||||
pidDir = mkOption {
|
||||
default = "/var/run/mysql";
|
||||
description = "Location of the file which stores the PID of the MySQL server";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,22 +1,52 @@
|
|||
args: with args;
|
||||
{pkgs, config}:
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.mysql;
|
||||
mysqlService = import ../services/mysql {
|
||||
inherit (pkgs) stdenv mysql;
|
||||
inherit (cfg) port user dataDir
|
||||
logError pidFile;
|
||||
};
|
||||
cfg = config.services.mysql;
|
||||
|
||||
mysql = pkgs.mysql;
|
||||
|
||||
pidFile = "${cfg.pidDir}/mysqld.pid";
|
||||
|
||||
mysqldOptions =
|
||||
"--user=${cfg.user} --datadir=${cfg.dataDir} " +
|
||||
"--log-error=${cfg.logError} --pid-file=${pidFile}";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
name = "mysql";
|
||||
job = "
|
||||
description \"MySQL server\"
|
||||
name = "mysql";
|
||||
|
||||
users = [
|
||||
{ name = "mysql";
|
||||
description = "MySQL server user";
|
||||
}
|
||||
];
|
||||
|
||||
stop on shutdown
|
||||
extraPath = [mysql];
|
||||
|
||||
job = ''
|
||||
description "MySQL server"
|
||||
|
||||
respawn ${mysqlService}/bin/control start
|
||||
";
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
if ! test -e ${cfg.dataDir}; then
|
||||
mkdir -m 0700 -p ${cfg.dataDir}
|
||||
chown -R ${cfg.user} ${cfg.dataDir}
|
||||
${mysql}/bin/mysql_install_db ${mysqldOptions}
|
||||
fi
|
||||
|
||||
mkdir -m 0700 -p ${cfg.pidDir}
|
||||
chown -R ${cfg.user} ${cfg.pidDir}
|
||||
end script
|
||||
|
||||
respawn ${mysql}/bin/mysqld ${mysqldOptions}
|
||||
|
||||
stop script
|
||||
pid=$(cat ${pidFile})
|
||||
kill "$pid"
|
||||
${mysql}/bin/mysql_waitpid "$pid" 1000
|
||||
end script
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue