From f8821473b13857011fb66dcd0d98b1961500e857 Mon Sep 17 00:00:00 2001 From: Sergey Gulin Date: Wed, 17 Jan 2024 10:14:03 +0300 Subject: [PATCH] [OPS-1402] Add systemd unit restart policy 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. --- modules/cors-proxy.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/cors-proxy.nix b/modules/cors-proxy.nix index fb7e550..4c9dcfc 100644 --- a/modules/cors-proxy.nix +++ b/modules/cors-proxy.nix @@ -45,6 +45,12 @@ in { script = '' ${cfg.package}/bin/@isomorphic-git/cors-proxy start ''; + startLimitBurst = 5; + startLimitIntervalSec = 300; + serviceConfig = { + Restart = "on-failure"; + RestartSec = 10; + }; environment = { PORT = toString cfg.port; ALLOW_ORIGIN = cfg.allowOrigin;