Created
October 18, 2020 19:06
-
-
Save grazor/eb9a6bd224a8ee618f5b0c721d8124b8 to your computer and use it in GitHub Desktop.
Nixos redis-sentinel config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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