* 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... 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 { allowedHosts = mkOption {
default = []; default = [];
description = " description = "

View File

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

View File

@ -1,30 +1,48 @@
args: with args; {pkgs, config}:
let let
cfg = config.services.postgresql; cfg = config.services.postgresql;
postgresqlService = import ../services/postgresql {
inherit (pkgs) stdenv postgresql su; postgresql = pkgs.postgresql;
inherit (cfg) port logDir dataDir
subServices allowedHosts startDependency = if config.services.gw6c.enable then
authMethod; "gw6c" else "network-interfaces";
serverUser = "postgres";
}; run = "${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh postgres";
in in
{ {
name = "postgresql"; name = "postgresql";
users = [ {
name = "postgres"; users = [
{ name = "postgres";
description = "PostgreSQL server user"; description = "PostgreSQL server user";
} ]; }
groups = [{name = "postgres";}]; ];
job = "
description \"PostgreSQL server\" groups = [
{ name = "postgres"; }
];
extraPath = [postgresql];
job = ''
description "PostgreSQL server"
start on ${startDependency}/started start on ${startDependency}/started
stop on shutdown stop on shutdown
respawn ${postgresqlService}/bin/control start 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}'
'';
} }