9 cfg = config.services.aerospike;
11 aerospikeConf = pkgs.writeText "aerospike.conf" ''
12 # This stanza must come first.
16 paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
18 work-directory ${cfg.workDir}
26 system-path ${cfg.package}/share/udf/lua
27 user-path ${cfg.workDir}/udf/lua
43 services.aerospike = {
44 enable = lib.mkEnableOption "Aerospike server";
46 package = lib.mkPackageOption pkgs "aerospike" { };
48 workDir = lib.mkOption {
50 default = "/var/lib/aerospike";
51 description = "Location where Aerospike stores its files";
54 networkConfig = lib.mkOption {
55 type = lib.types.lines;
80 description = "network section of configuration file";
83 extraConfig = lib.mkOption {
84 type = lib.types.lines;
94 description = "Extra configuration";
100 ###### implementation
102 config = lib.mkIf config.services.aerospike.enable {
104 users.users.aerospike = {
107 uid = config.ids.uids.aerospike;
108 description = "Aerospike server user";
110 users.groups.aerospike.gid = config.ids.gids.aerospike;
112 boot.kernel.sysctl = {
113 "net.core.rmem_max" = lib.mkDefault 15728640;
114 "net.core.wmem_max" = lib.mkDefault 5242880;
117 systemd.services.aerospike = rec {
118 description = "Aerospike server";
120 wantedBy = [ "multi-user.target" ];
121 after = [ "network.target" ];
124 ExecStart = "${cfg.package}/bin/asd --fgdaemon --config-file ${aerospikeConf}";
127 LimitNOFILE = 100000;
128 PermissionsStartOnly = true;
132 if [ $(echo "$(${pkgs.procps}/bin/sysctl -n kernel.shmall) < 4294967296" | ${pkgs.bc}/bin/bc) == "1" ]; then
133 echo "kernel.shmall too low, setting to 4G pages"
134 ${pkgs.procps}/bin/sysctl -w kernel.shmall=4294967296
136 if [ $(echo "$(${pkgs.procps}/bin/sysctl -n kernel.shmmax) < 1073741824" | ${pkgs.bc}/bin/bc) == "1" ]; then
137 echo "kernel.shmmax too low, setting to 1GB"
138 ${pkgs.procps}/bin/sysctl -w kernel.shmmax=1073741824
140 install -d -m0700 -o ${serviceConfig.User} -g ${serviceConfig.Group} "${cfg.workDir}"
141 install -d -m0700 -o ${serviceConfig.User} -g ${serviceConfig.Group} "${cfg.workDir}/smd"
142 install -d -m0700 -o ${serviceConfig.User} -g ${serviceConfig.Group} "${cfg.workDir}/udf"
143 install -d -m0700 -o ${serviceConfig.User} -g ${serviceConfig.Group} "${cfg.workDir}/udf/lua"