forked from mirrors/nixpkgs
nixos/graphite-service: fix startup issue
The preStart snippets (graphite, carbon) try to create directories under /var/db/. That currently fails because the code is run as user "graphite". Fix by setting "PermissionsStartOnly = true" so that the preStart stuff is run as 'root'. Further: * graphite-web-0.9.12/bin/build-index.sh needs perl, so add it to PATH. * Now that preStart runs as root, we must wait with "chown graphite" until we're done creating files/directories. * Drop needless check for root (uid 0) before running chown.
This commit is contained in:
parent
e572b5c104
commit
ffb593f880
|
@ -184,6 +184,7 @@ in {
|
||||||
ExecStart = "${pkgs.twisted}/bin/twistd ${carbonOpts "carbon-cache"}";
|
ExecStart = "${pkgs.twisted}/bin/twistd ${carbonOpts "carbon-cache"}";
|
||||||
User = "graphite";
|
User = "graphite";
|
||||||
Group = "graphite";
|
Group = "graphite";
|
||||||
|
PermissionsStartOnly = true;
|
||||||
};
|
};
|
||||||
restartTriggers = [
|
restartTriggers = [
|
||||||
pkgs.pythonPackages.carbon
|
pkgs.pythonPackages.carbon
|
||||||
|
@ -194,7 +195,7 @@ in {
|
||||||
];
|
];
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -m 0700 -p ${cfg.dataDir}/whisper
|
mkdir -m 0700 -p ${cfg.dataDir}/whisper
|
||||||
if [ "$(id -u)" = 0 ]; then chown -R graphite:graphite ${cfg.dataDir}; fi
|
chown -R graphite:graphite ${cfg.dataDir}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -235,6 +236,7 @@ in {
|
||||||
description = "Graphite Web Interface";
|
description = "Graphite Web Interface";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network-interfaces.target" ];
|
after = [ "network-interfaces.target" ];
|
||||||
|
path = [ pkgs.perl ];
|
||||||
environment = {
|
environment = {
|
||||||
PYTHONPATH = "${pkgs.python27Packages.graphite_web}/lib/python2.7/site-packages";
|
PYTHONPATH = "${pkgs.python27Packages.graphite_web}/lib/python2.7/site-packages";
|
||||||
DJANGO_SETTINGS_MODULE = "graphite.settings";
|
DJANGO_SETTINGS_MODULE = "graphite.settings";
|
||||||
|
@ -248,11 +250,11 @@ in {
|
||||||
--call django.core.handlers.wsgi:WSGIHandler'';
|
--call django.core.handlers.wsgi:WSGIHandler'';
|
||||||
User = "graphite";
|
User = "graphite";
|
||||||
Group = "graphite";
|
Group = "graphite";
|
||||||
|
PermissionsStartOnly = true;
|
||||||
};
|
};
|
||||||
preStart = ''
|
preStart = ''
|
||||||
if ! test -e ${dataDir}/db-created; then
|
if ! test -e ${dataDir}/db-created; then
|
||||||
mkdir -m 0700 -p ${dataDir}/{whisper/,log/webapp/}
|
mkdir -m 0700 -p ${dataDir}/{whisper/,log/webapp/}
|
||||||
if [ "$(id -u)" = 0 ]; then chown -R graphite:graphite ${cfg.dataDir}; fi
|
|
||||||
|
|
||||||
# populate database
|
# populate database
|
||||||
${pkgs.python27Packages.graphite_web}/bin/manage-graphite.py syncdb --noinput
|
${pkgs.python27Packages.graphite_web}/bin/manage-graphite.py syncdb --noinput
|
||||||
|
@ -261,6 +263,8 @@ in {
|
||||||
${pkgs.python27Packages.graphite_web}/bin/build-index.sh
|
${pkgs.python27Packages.graphite_web}/bin/build-index.sh
|
||||||
|
|
||||||
touch ${dataDir}/db-created
|
touch ${dataDir}/db-created
|
||||||
|
|
||||||
|
chown -R graphite:graphite ${cfg.dataDir}
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
restartTriggers = [
|
restartTriggers = [
|
||||||
|
|
Loading…
Reference in a new issue