* 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:
Eelco Dolstra 2008-06-25 21:58:51 +00:00
parent 314ab9774f
commit 90acbf9509
2 changed files with 46 additions and 16 deletions

View File

@ -1933,7 +1933,7 @@
}; };
user = mkOption { user = mkOption {
default = "nobody"; default = "mysql";
description = "User account under which MySQL runs"; description = "User account under which MySQL runs";
}; };
@ -1947,8 +1947,8 @@
description = "Location of the MySQL error logfile"; description = "Location of the MySQL error logfile";
}; };
pidFile = mkOption { pidDir = mkOption {
default = "/var/mysql/mysql.pid"; default = "/var/run/mysql";
description = "Location of the file which stores the PID of the MySQL server"; description = "Location of the file which stores the PID of the MySQL server";
}; };
}; };

View File

@ -1,22 +1,52 @@
args: with args; {pkgs, config}:
let let
cfg = config.services.mysql; cfg = config.services.mysql;
mysqlService = import ../services/mysql {
inherit (pkgs) stdenv mysql; mysql = pkgs.mysql;
inherit (cfg) port user dataDir
logError pidFile; pidFile = "${cfg.pidDir}/mysqld.pid";
};
mysqldOptions =
"--user=${cfg.user} --datadir=${cfg.dataDir} " +
"--log-error=${cfg.logError} --pid-file=${pidFile}";
in in
{ {
name = "mysql"; name = "mysql";
job = "
description \"MySQL server\" users = [
{ name = "mysql";
description = "MySQL server user";
}
];
extraPath = [mysql];
job = ''
description "MySQL server"
stop on shutdown stop on shutdown
respawn ${mysqlService}/bin/control start 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
'';
} }