From 1e682a85c4dbc98cad8e2a940e1759a66941df58 Mon Sep 17 00:00:00 2001 From: Shivaraj B H Date: Fri, 4 Oct 2024 22:00:59 +0530 Subject: [PATCH] refactor: consolidate all settings in `defaultProcessSettings` (#348) --- nix/lib.nix | 12 ++++++++++++ nix/services/apache-kafka.nix | 5 ----- nix/services/cassandra.nix | 10 ---------- nix/services/clickhouse/default.nix | 10 ---------- nix/services/elasticsearch.nix | 8 -------- nix/services/grafana.nix | 8 -------- nix/services/memcached.nix | 5 ----- nix/services/mysql/default.nix | 10 ---------- nix/services/nginx/default.nix | 10 ---------- nix/services/ollama.nix | 5 ----- nix/services/open-webui.nix | 5 ----- nix/services/pgadmin.nix | 10 ---------- nix/services/postgres/default.nix | 10 ---------- nix/services/prometheus.nix | 10 ---------- nix/services/redis-cluster.nix | 10 ---------- nix/services/redis.nix | 11 ----------- nix/services/searxng.nix | 5 ----- nix/services/tempo.nix | 3 --- nix/services/tika.nix | 5 ----- nix/services/weaviate.nix | 10 ---------- nix/services/zookeeper.nix | 5 ----- 21 files changed, 12 insertions(+), 155 deletions(-) diff --git a/nix/lib.nix b/nix/lib.nix index a9078f48..908a060d 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -38,6 +38,18 @@ ''; default = { namespace = lib.mkDefault config.namespace; + # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy + availability = { + restart = lib.mkDefault "on_failure"; + max_restarts = lib.mkDefault 5; + }; + readiness_probe = { + initial_delay_seconds = lib.mkDefault 2; + period_seconds = lib.mkDefault 10; + timeout_seconds = lib.mkDefault 4; + success_threshold = lib.mkDefault 1; + failure_threshold = lib.mkDefault 5; + }; }; }; settings = lib.mkOption { diff --git a/nix/services/apache-kafka.nix b/nix/services/apache-kafka.nix index 642cbf80..51d45bd6 100644 --- a/nix/services/apache-kafka.nix +++ b/nix/services/apache-kafka.nix @@ -170,11 +170,6 @@ with lib; readiness_probe = { # TODO: need to find a better way to check if kafka is ready. Maybe use one of the scripts in bin? exec.command = "${pkgs.netcat.nc}/bin/nc -z localhost ${builtins.toString config.port}"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; availability = { diff --git a/nix/services/cassandra.nix b/nix/services/cassandra.nix index 8c23b3ca..184c6f01 100644 --- a/nix/services/cassandra.nix +++ b/nix/services/cassandra.nix @@ -146,18 +146,8 @@ in exec.command = '' echo 'show version;' | CQLSH_HOST=${config.listenAddress} CQLSH_PORT=${toString config.nativeTransportPort} ${config.package}/bin/cqlsh ''; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/clickhouse/default.nix b/nix/services/clickhouse/default.nix index f31bbf0b..14c37f4b 100644 --- a/nix/services/clickhouse/default.nix +++ b/nix/services/clickhouse/default.nix @@ -154,18 +154,8 @@ in host = "localhost"; port = if (lib.hasAttr "http_port" config.extraConfig) then config.extraConfig.http_port else 8123; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; depends_on."${name}-init".condition = "process_completed_successfully"; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/elasticsearch.nix b/nix/services/elasticsearch.nix index 07da86b0..4186bdc1 100644 --- a/nix/services/elasticsearch.nix +++ b/nix/services/elasticsearch.nix @@ -185,17 +185,9 @@ in readiness_probe = { exec.command = "${pkgs.curl}/bin/curl -f -k http://${config.listenAddress}:${toString config.port}"; initial_delay_seconds = 15; - period_seconds = 10; timeout_seconds = 2; - success_threshold = 1; - failure_threshold = 5; }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/grafana.nix b/nix/services/grafana.nix index db07d3f6..daf4fa80 100644 --- a/nix/services/grafana.nix +++ b/nix/services/grafana.nix @@ -154,17 +154,9 @@ in path = "/api/health"; }; initial_delay_seconds = 15; - period_seconds = 10; timeout_seconds = 2; - success_threshold = 1; - failure_threshold = 5; }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/memcached.nix b/nix/services/memcached.nix index be6b7103..bcd08cc7 100644 --- a/nix/services/memcached.nix +++ b/nix/services/memcached.nix @@ -45,11 +45,6 @@ in exec.command = '' echo -e "stats\nquit" | ${pkgs.netcat}/bin/nc ${config.bind} ${toString config.port} > /dev/null 2>&1 ''; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy diff --git a/nix/services/mysql/default.nix b/nix/services/mysql/default.nix index d3c6fcbc..e4d1ce2a 100644 --- a/nix/services/mysql/default.nix +++ b/nix/services/mysql/default.nix @@ -284,18 +284,8 @@ in # Turns out using `--defaults-file` alone doesn't make the readiness_probe work unless `MYSQL_UNIX_PORT` is set. # Hence the use of `--socket`. exec.command = "${config.package}/bin/mysqladmin --socket=${config.socketDir}/mysql.sock ping -h localhost"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - 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 47453d2c..f1738f1f 100644 --- a/nix/services/nginx/default.nix +++ b/nix/services/nginx/default.nix @@ -102,16 +102,6 @@ in readiness_probe = { # FIXME need a better health check exec.command = "[ -e ${config.dataDir}/nginx/nginx.pid ]"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; - }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; }; }; }; diff --git a/nix/services/ollama.nix b/nix/services/ollama.nix index 639a0804..b4330579 100644 --- a/nix/services/ollama.nix +++ b/nix/services/ollama.nix @@ -104,11 +104,6 @@ in host = config.host; port = config.port; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; availability = { restart = "on_failure"; diff --git a/nix/services/open-webui.nix b/nix/services/open-webui.nix index d63511bd..44b0b929 100644 --- a/nix/services/open-webui.nix +++ b/nix/services/open-webui.nix @@ -83,11 +83,6 @@ in host = config.host; port = config.port; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; availability = { restart = "on_failure"; diff --git a/nix/services/pgadmin.nix b/nix/services/pgadmin.nix index bff99243..09a37bdc 100644 --- a/nix/services/pgadmin.nix +++ b/nix/services/pgadmin.nix @@ -151,18 +151,8 @@ in port = config.port; path = "/misc/ping"; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; depends_on."${name}-init".condition = "process_completed_successfully"; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/postgres/default.nix b/nix/services/postgres/default.nix index f170efe7..72c12222 100644 --- a/nix/services/postgres/default.nix +++ b/nix/services/postgres/default.nix @@ -326,18 +326,8 @@ in shutdown.signal = 2; readiness_probe = { exec.command = "${config.package}/bin/pg_isready ${lib.concatStringsSep " " pg_isreadyArgs}"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; depends_on."${name}-init".condition = "process_completed_successfully"; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/prometheus.nix b/nix/services/prometheus.nix index cf04b21a..4cfb1e9c 100644 --- a/nix/services/prometheus.nix +++ b/nix/services/prometheus.nix @@ -82,18 +82,8 @@ in port = config.port; path = "/-/ready"; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; - }; }; }; }; diff --git a/nix/services/redis-cluster.nix b/nix/services/redis-cluster.nix index 9afba325..9d8f6711 100644 --- a/nix/services/redis-cluster.nix +++ b/nix/services/redis-cluster.nix @@ -103,18 +103,8 @@ in readiness_probe = { exec.command = "${config.package}/bin/redis-cli -p ${port} ping"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - 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 ef722e26..2aefab12 100644 --- a/nix/services/redis.nix +++ b/nix/services/redis.nix @@ -67,17 +67,6 @@ in readiness_probe = { exec.command = "${config.package}/bin/redis-cli -p ${toString config.port} ping"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; - }; - - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; }; }; }; diff --git a/nix/services/searxng.nix b/nix/services/searxng.nix index 1b30b0ac..573a1edd 100644 --- a/nix/services/searxng.nix +++ b/nix/services/searxng.nix @@ -72,11 +72,6 @@ in host = config.host; port = config.port; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; }; }; diff --git a/nix/services/tempo.nix b/nix/services/tempo.nix index 22e6e966..1d12bbdb 100644 --- a/nix/services/tempo.nix +++ b/nix/services/tempo.nix @@ -112,10 +112,7 @@ in path = "/ready"; }; initial_delay_seconds = 15; - period_seconds = 10; timeout_seconds = 2; - success_threshold = 1; - failure_threshold = 5; }; availability = { restart = "on_failure"; diff --git a/nix/services/tika.nix b/nix/services/tika.nix index 9eac4a9f..754330cb 100644 --- a/nix/services/tika.nix +++ b/nix/services/tika.nix @@ -58,11 +58,6 @@ in host = config.host; port = config.port; }; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; }; }; diff --git a/nix/services/weaviate.nix b/nix/services/weaviate.nix index 94c6d0ce..9b410cdd 100644 --- a/nix/services/weaviate.nix +++ b/nix/services/weaviate.nix @@ -73,16 +73,6 @@ in path = "/v1/.well-known/ready"; }; initial_delay_seconds = 3; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; - }; - - # https://github.com/F1bonacc1/process-compose#-auto-restart-if-not-healthy - availability = { - restart = "on_failure"; - max_restarts = 5; }; }; }; diff --git a/nix/services/zookeeper.nix b/nix/services/zookeeper.nix index 0ddc1b3b..2eb07768 100644 --- a/nix/services/zookeeper.nix +++ b/nix/services/zookeeper.nix @@ -132,11 +132,6 @@ with lib; readiness_probe = { exec.command = "echo stat | ${pkgs.netcat.nc}/bin/nc localhost ${toString config.port}"; - initial_delay_seconds = 2; - period_seconds = 10; - timeout_seconds = 4; - success_threshold = 1; - failure_threshold = 5; }; availability = {