* Postgres job: start postgres directly, don't use the old control

script from the services tree.

svn path=/nixos/trunk/; revision=10722
This commit is contained in:
Eelco Dolstra 2008-02-18 11:56:43 +00:00
parent b98cb9a770
commit 8a1d362447
3 changed files with 50 additions and 23 deletions

View File

@ -1693,6 +1693,17 @@
here is an interface...
";
};
authentication = mkOption {
default = ''
# Generated file; do not edit!
local all all ident sameuser
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
'';
description = "
Hosts (except localhost), who you allow to connect.
";
};
allowedHosts = mkOption {
default = [];
description = "

View File

@ -177,8 +177,6 @@ let
++ optional config.services.postgresql.enable
(import ../upstart-jobs/postgresql.nix {
inherit config pkgs;
startDependency = if config.services.gw6c.enable then
"gw6c" else "network-interfaces";
})
# EJabberd service

View File

@ -1,30 +1,48 @@
args: with args;
{pkgs, config}:
let
cfg = config.services.postgresql;
postgresqlService = import ../services/postgresql {
inherit (pkgs) stdenv postgresql su;
inherit (cfg) port logDir dataDir
subServices allowedHosts
authMethod;
serverUser = "postgres";
};
cfg = config.services.postgresql;
postgresql = pkgs.postgresql;
startDependency = if config.services.gw6c.enable then
"gw6c" else "network-interfaces";
run = "${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh postgres";
in
{
name = "postgresql";
users = [ {
name = "postgres";
description = "PostgreSQL server user";
} ];
groups = [{name = "postgres";}];
job = "
description \"PostgreSQL server\"
name = "postgresql";
start on ${startDependency}/started
stop on shutdown
users = [
{ name = "postgres";
description = "PostgreSQL server user";
}
];
respawn ${postgresqlService}/bin/control start
";
groups = [
{ name = "postgres"; }
];
extraPath = [postgresql];
job = ''
description "PostgreSQL server"
start on ${startDependency}/started
stop on shutdown
start script
if ! test -e ${cfg.dataDir}; then
mkdir -m 0700 -p ${cfg.dataDir}
chown -R postgres ${cfg.dataDir}
${run} -c '${postgresql}/bin/initdb -D ${cfg.dataDir} -U root'
fi
cp -f ${pkgs.writeText "pg_hba.conf" cfg.authentication} ${cfg.dataDir}/pg_hba.conf
end script
respawn ${run} -c '${postgresql}/bin/postgres -D ${cfg.dataDir}'
'';
}