From 14ff9f81cf07170aa3c3e92cfd48d42cfdf6299f Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Wed, 4 Sep 2024 16:48:38 +0530 Subject: [PATCH] feat: Add `max_restarts` to all services to avoid restarting indefinitely --- nix/services/apache-kafka.nix | 5 ++++- nix/services/cassandra.nix | 5 ++++- nix/services/clickhouse/default.nix | 5 ++++- nix/services/elasticsearch.nix | 5 ++++- nix/services/grafana.nix | 5 ++++- nix/services/mysql/default.nix | 5 ++++- nix/services/nginx/default.nix | 5 ++++- nix/services/ollama.nix | 5 ++++- nix/services/open-webui.nix | 5 ++++- nix/services/pgadmin.nix | 5 ++++- nix/services/postgres/default.nix | 5 ++++- nix/services/prometheus.nix | 5 ++++- nix/services/redis-cluster.nix | 5 ++++- nix/services/redis.nix | 5 ++++- nix/services/searxng.nix | 5 ++++- nix/services/tempo.nix | 5 ++++- nix/services/tika.nix | 5 ++++- nix/services/weaviate.nix | 5 ++++- nix/services/zookeeper.nix | 5 ++++- 19 files changed, 76 insertions(+), 19 deletions(-) diff --git a/nix/services/apache-kafka.nix b/nix/services/apache-kafka.nix index 53c51fd1..642cbf80 100644 --- a/nix/services/apache-kafka.nix +++ b/nix/services/apache-kafka.nix @@ -177,7 +177,10 @@ with lib; failure_threshold = 5; }; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/cassandra.nix b/nix/services/cassandra.nix index bc194990..8c23b3ca 100644 --- a/nix/services/cassandra.nix +++ b/nix/services/cassandra.nix @@ -154,7 +154,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/clickhouse/default.nix b/nix/services/clickhouse/default.nix index 6a4d7d57..f31bbf0b 100644 --- a/nix/services/clickhouse/default.nix +++ b/nix/services/clickhouse/default.nix @@ -162,7 +162,10 @@ in }; depends_on."${name}-init".condition = "process_completed_successfully"; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/elasticsearch.nix b/nix/services/elasticsearch.nix index c974d218..ba00c820 100644 --- a/nix/services/elasticsearch.nix +++ b/nix/services/elasticsearch.nix @@ -190,7 +190,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/grafana.nix b/nix/services/grafana.nix index 0c83d028..db07d3f6 100644 --- a/nix/services/grafana.nix +++ b/nix/services/grafana.nix @@ -161,7 +161,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/mysql/default.nix b/nix/services/mysql/default.nix index b3434d07..d3c6fcbc 100644 --- a/nix/services/mysql/default.nix +++ b/nix/services/mysql/default.nix @@ -292,7 +292,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; "${name}-configure" = { command = configureScript; diff --git a/nix/services/nginx/default.nix b/nix/services/nginx/default.nix index 7f21b327..47453d2c 100644 --- a/nix/services/nginx/default.nix +++ b/nix/services/nginx/default.nix @@ -109,7 +109,10 @@ in failure_threshold = 5; }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/ollama.nix b/nix/services/ollama.nix index e8f9015b..639a0804 100644 --- a/nix/services/ollama.nix +++ b/nix/services/ollama.nix @@ -110,7 +110,10 @@ in success_threshold = 1; failure_threshold = 5; }; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; "${name}-models" = { diff --git a/nix/services/open-webui.nix b/nix/services/open-webui.nix index bd73fa88..d63511bd 100644 --- a/nix/services/open-webui.nix +++ b/nix/services/open-webui.nix @@ -89,7 +89,10 @@ in success_threshold = 1; failure_threshold = 5; }; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/pgadmin.nix b/nix/services/pgadmin.nix index 674860f7..bff99243 100644 --- a/nix/services/pgadmin.nix +++ b/nix/services/pgadmin.nix @@ -159,7 +159,10 @@ in }; depends_on."${name}-init".condition = "process_completed_successfully"; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/postgres/default.nix b/nix/services/postgres/default.nix index 1df1d26f..f170efe7 100644 --- a/nix/services/postgres/default.nix +++ b/nix/services/postgres/default.nix @@ -334,7 +334,10 @@ in }; depends_on."${name}-init".condition = "process_completed_successfully"; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/prometheus.nix b/nix/services/prometheus.nix index f3fc28a0..cf04b21a 100644 --- a/nix/services/prometheus.nix +++ b/nix/services/prometheus.nix @@ -90,7 +90,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/redis-cluster.nix b/nix/services/redis-cluster.nix index ea9626d7..9afba325 100644 --- a/nix/services/redis-cluster.nix +++ b/nix/services/redis-cluster.nix @@ -111,7 +111,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; hosts = lib.mapAttrsToList (_: cfg: "${config.bind}:${builtins.toString cfg.port}") config.nodes; clusterCreateScript = pkgs.writeShellApplication { diff --git a/nix/services/redis.nix b/nix/services/redis.nix index decef6f0..ef722e26 100644 --- a/nix/services/redis.nix +++ b/nix/services/redis.nix @@ -75,7 +75,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/searxng.nix b/nix/services/searxng.nix index 0145232f..1b30b0ac 100644 --- a/nix/services/searxng.nix +++ b/nix/services/searxng.nix @@ -63,7 +63,10 @@ in )}"; }; command = lib.getExe config.package; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; readiness_probe = { http_get = { host = config.host; diff --git a/nix/services/tempo.nix b/nix/services/tempo.nix index e9cdc2c0..22e6e966 100644 --- a/nix/services/tempo.nix +++ b/nix/services/tempo.nix @@ -117,7 +117,10 @@ in success_threshold = 1; failure_threshold = 5; }; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/tika.nix b/nix/services/tika.nix index 63d2382d..9eac4a9f 100644 --- a/nix/services/tika.nix +++ b/nix/services/tika.nix @@ -49,7 +49,10 @@ in in { command = "${lib.getExe tikaPackage} --host ${config.host} --port ${toString config.port} ${lib.optionalString (config.configFile != null) "--config ${config.configFile}"}"; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; readiness_probe = { http_get = { host = config.host; diff --git a/nix/services/weaviate.nix b/nix/services/weaviate.nix index d2ec7e4f..94c6d0ce 100644 --- a/nix/services/weaviate.nix +++ b/nix/services/weaviate.nix @@ -80,7 +80,10 @@ in }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; }; diff --git a/nix/services/zookeeper.nix b/nix/services/zookeeper.nix index cb541399..0ddc1b3b 100644 --- a/nix/services/zookeeper.nix +++ b/nix/services/zookeeper.nix @@ -139,7 +139,10 @@ with lib; failure_threshold = 5; }; - availability.restart = "on_failure"; + availability = { + restart = "on_failure"; + max_restarts = 5; + }; }; }; };