Skip to content

Commit

Permalink
refactor: consolidate all settings in `defaultProcessSettings"
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaraj-bh committed Oct 4, 2024
1 parent 8bb221b commit e7b895a
Show file tree
Hide file tree
Showing 21 changed files with 12 additions and 155 deletions.
12 changes: 12 additions & 0 deletions nix/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions nix/services/apache-kafka.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 0 additions & 10 deletions nix/services/cassandra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
10 changes: 0 additions & 10 deletions nix/services/clickhouse/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
8 changes: 0 additions & 8 deletions nix/services/elasticsearch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
8 changes: 0 additions & 8 deletions nix/services/grafana.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
5 changes: 0 additions & 5 deletions nix/services/memcached.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions nix/services/mysql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions nix/services/nginx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down
5 changes: 0 additions & 5 deletions nix/services/ollama.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 0 additions & 5 deletions nix/services/open-webui.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 0 additions & 10 deletions nix/services/pgadmin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
10 changes: 0 additions & 10 deletions nix/services/postgres/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
10 changes: 0 additions & 10 deletions nix/services/prometheus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
};
Expand Down
10 changes: 0 additions & 10 deletions nix/services/redis-cluster.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 0 additions & 11 deletions nix/services/redis.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down
5 changes: 0 additions & 5 deletions nix/services/searxng.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down
3 changes: 0 additions & 3 deletions nix/services/tempo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 0 additions & 5 deletions nix/services/tika.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down
10 changes: 0 additions & 10 deletions nix/services/weaviate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down
5 changes: 0 additions & 5 deletions nix/services/zookeeper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit e7b895a

Please sign in to comment.