Skip to content

Instantly share code, notes, and snippets.

@grazor
Created October 18, 2020 19:06
Show Gist options
  • Save grazor/eb9a6bd224a8ee618f5b0c721d8124b8 to your computer and use it in GitHub Desktop.
Save grazor/eb9a6bd224a8ee618f5b0c721d8124b8 to your computer and use it in GitHub Desktop.
Nixos redis-sentinel config
{ config, pkgs, ... }:
let
cfg = config.services.redis;
sentinelConfig = pkgs.writeText "sentinel.conf" ''
port 26379
sentinel monitor mymaster 127.0.0.1 6379 1
'';
in {
systemd.services.redis-sentinel = {
description = "Redis-sentinel daemon";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
preStart = ''
install -m 600 ${sentinelConfig} /run/redis/sentinel.conf
'';
serviceConfig = {
User = "redis";
Group = "redis";
ExecStart = "${cfg.package}/bin/redis-sentinel /run/redis/sentinel.conf";
ExecStop = "${cfg.package}/bin/redis-cli -p 26379 shutdown";
Restart = "always";
};
};
services.redis.enable = true;
systemd.services.redis-sentinel.enable = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment