3
0
Fork 0
forked from mirrors/nixpkgs

nixos/couchdb: fix stopping of service, by making it non-forking, a few other improvments

Conflicts:
	nixos/modules/services/databases/couchdb.nix
This commit is contained in:
Jaka Hudoklin 2014-03-10 11:06:48 +01:00
parent 086afe9161
commit 993ef8287e

View file

@ -1,9 +1,7 @@
{ config, pkgs, ... }:
with pkgs.lib;
with pkgs.lib;
let
cfg = config.services.couchdb;
configFile = pkgs.writeText "couchdb.ini"
''
@ -19,10 +17,8 @@ let
[log]
file = ${cfg.logFile}
'';
configExtraFile = pkgs.writeText "couchdb-extra.ini" cfg.extraConfig;
in
{
in {
###### interface
@ -64,14 +60,6 @@ in
'';
};
pidFile = mkOption {
type = types.path;
default = "/var/run/couchdb/couchdb.pid";
description = ''
pid file.
'';
};
# couchdb options: http://docs.couchdb.org/en/latest/config/index.html
databaseDir = mkOption {
@ -153,26 +141,23 @@ in
preStart =
''
mkdir -p `dirname ${cfg.pidFile}`;
mkdir -p `dirname ${cfg.uriFile}`;
mkdir -p `dirname ${cfg.logFile}`;
touch ${cfg.logFile};
mkdir -p ${cfg.databaseDir};
mkdir -p ${cfg.viewIndexDir};
chown ${cfg.user}:${cfg.group} `dirname ${cfg.pidFile}`
chown ${cfg.user}:${cfg.group} `dirname ${cfg.uriFile}`
chown ${cfg.user}:${cfg.group} ${cfg.logFile}
chown ${cfg.user}:${cfg.group} ${cfg.databaseDir}
chown ${cfg.user}:${cfg.group} ${cfg.viewIndexDir}
if [ "$(id -u)" = 0 ]; then
chown ${cfg.user}:${cfg.group} `dirname ${cfg.uriFile}`
chown ${cfg.user}:${cfg.group} ${cfg.databaseDir}
chown ${cfg.user}:${cfg.group} ${cfg.viewIndexDir}
fi
'';
serviceConfig = {
PermissionsStartOnly = true;
User = cfg.user;
Group = cfg.group;
Type = "forking";
ExecStart = "${cfg.package}/bin/couchdb -b -o /dev/null -e /dev/null -p ${cfg.pidFile} -a ${configFile} -a ${configExtraFile}";
ExecStop = "${cfg.package}/bin/couchdb -d";
ExecStart = "${cfg.package}/bin/couchdb -a ${configFile} -a ${pkgs.writeText "couchdb-extra.ini" cfg.extraConfig}";
};
};