Skip to content

Commit

Permalink
[Chore] Add systemd unit restart policy
Browse files Browse the repository at this point in the history
Problem: By default, systemd services generated from the NixOS system configuration don't attempt to restart on failure since Restart=no. However, in some cases, running processes can fail for unclear reasons, and the simplest way to bring the failed service back to life is to restart it. Instead, currently, the service will fail and trigger an alert without attempting to restart.

Solution: Add default values for startLimitBurst, startLimitIntervalSec, Restart, and RestartSec.
  • Loading branch information
Sereja313 committed Dec 22, 2023
1 parent 3119cde commit c23b821
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MPL-2.0
{ self, ... }@inputs: { config, pkgs, lib, ... }:
let
inherit (lib) mkEnableOption mkOption types mkIf;
inherit (lib) mkEnableOption mkOption types mkIf mkDefault;
in
{
options.services.tzbot = {
Expand Down Expand Up @@ -50,10 +50,14 @@ in
export SLACK_TZ_BOT_TOKEN="${cfg.slackBotToken}"
${cfg.package}/bin/tzbot-exe --config ${pkgs.writeText "config.yml" (builtins.toJSON cfg.botConfig)}
'';
startLimitBurst = mkDefault 5;
startLimitIntervalSec = mkDefault 300;
serviceConfig = {
User = "tzbot";
Group = "tzbot";
StateDirectory = "tzbot";
Restart = mkDefault "on-failure";
RestartSec = mkDefault 10;
};
};
users.users.tzbot = {
Expand Down

0 comments on commit c23b821

Please sign in to comment.