1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 19:51:17 +00:00

nixos/cassandra: Prepare for cassandra 4

Its scripts disagree a bit with our flexible
logging approach and our default logging config.
Might want to revisit this at some point.

The `mkdir` failures in the log are harmless.
This commit is contained in:
Robert Hensing 2022-04-06 12:59:48 +02:00 committed by Manuel Bärenz
parent 90b1c9fa10
commit 5775cfa4b8

View file

@ -21,6 +21,7 @@ let
atLeast3 = versionAtLeast cfg.package.version "3";
atLeast3_11 = versionAtLeast cfg.package.version "3.11";
atLeast4 = versionAtLeast cfg.package.version "4";
defaultUser = "cassandra";
@ -65,7 +66,7 @@ let
cassandraLogbackConfig = pkgs.writeText "logback.xml" cfg.logbackConfig;
passAsFile = [ "extraEnvSh" ];
inherit (cfg) extraEnvSh;
inherit (cfg) extraEnvSh package;
buildCommand = ''
mkdir -p "$out"
@ -83,6 +84,10 @@ let
# Delete default password file
sed -i '/-Dcom.sun.management.jmxremote.password.file=\/etc\/cassandra\/jmxremote.password/d' "$out/cassandra-env.sh"
${lib.optionalString atLeast4 ''
cp $package/conf/jvm*.options $out/
''}
'';
};
@ -98,8 +103,20 @@ let
"-Dcom.sun.management.jmxremote.password.file=${cfg.jmxRolesFile}"
] ++ optionals cfg.remoteJmx [
"-Djava.rmi.server.hostname=${cfg.rpcAddress}"
] ++ optionals atLeast4 [
# Historically, we don't use a log dir, whereas the upstream scripts do
# expect this. We override those by providing our own -Xlog:gc flag.
"-Xlog:gc=warning,heap*=warning,age*=warning,safepoint=warning,promotion*=warning"
];
commonEnv = {
# Sufficient for cassandra 2.x, 3.x
CASSANDRA_CONF = "${cassandraEtc}";
# Required since cassandra 4
CASSANDRA_LOGBACK_CONF = "${cassandraEtc}/logback.xml";
};
in
{
options.services.cassandra = {
@ -489,8 +506,7 @@ in
systemd.services.cassandra = {
description = "Apache Cassandra service";
after = [ "network.target" ];
environment = {
CASSANDRA_CONF = "${cassandraEtc}";
environment = commonEnv // {
JVM_OPTS = builtins.concatStringsSep " " fullJvmOptions;
MAX_HEAP_SIZE = toString cfg.maxHeapSize;
HEAP_NEWSIZE = toString cfg.heapNewSize;
@ -511,6 +527,7 @@ in
description = "Perform a full repair on this Cassandra node";
after = [ "cassandra.service" ];
requires = [ "cassandra.service" ];
environment = commonEnv;
serviceConfig = {
User = cfg.user;
Group = cfg.group;
@ -539,6 +556,7 @@ in
description = "Perform an incremental repair on this cassandra node.";
after = [ "cassandra.service" ];
requires = [ "cassandra.service" ];
environment = commonEnv;
serviceConfig = {
User = cfg.user;
Group = cfg.group;