diff --git a/packages/sync-service/config/runtime.exs b/packages/sync-service/config/runtime.exs index 6b749cf70b..8c50de6f7d 100644 --- a/packages/sync-service/config/runtime.exs +++ b/packages/sync-service/config/runtime.exs @@ -231,4 +231,5 @@ config :electric, shape_hibernate_after: shape_hibernate_after, storage: storage, persistent_kv: persistent_kv, - listen_on_ipv6?: env!("ELECTRIC_LISTEN_ON_IPV6", :boolean, nil) + listen_on_ipv6?: env!("ELECTRIC_LISTEN_ON_IPV6", :boolean, nil), + compaction?: env!("ELECTRIC_COMPACTION", :boolean, true) diff --git a/packages/sync-service/lib/electric/shapes/consumer_supervisor.ex b/packages/sync-service/lib/electric/shapes/consumer_supervisor.ex index 4f29bafd8d..ae2e98e8da 100644 --- a/packages/sync-service/lib/electric/shapes/consumer_supervisor.ex +++ b/packages/sync-service/lib/electric/shapes/consumer_supervisor.ex @@ -73,10 +73,17 @@ defmodule Electric.Shapes.ConsumerSupervisor do children = [ {Electric.ShapeCache.Storage, shape_storage}, {Electric.Shapes.Consumer, shape_config}, - {Electric.Shapes.Consumer.Snapshotter, shape_config}, - {Electric.ShapeCache.CompactionRunner, [{:storage, shape_storage} | metadata]} + {Electric.Shapes.Consumer.Snapshotter, shape_config} ] + children = + if Application.get_env(:electric, :compaction?, true) do + children ++ + [{Electric.ShapeCache.CompactionRunner, [{:storage, shape_storage} | metadata]}] + else + children + end + Supervisor.init(children, strategy: :one_for_one, auto_shutdown: :any_significant) end end