commanded / eventstore

Event store using PostgreSQL for persistence
MIT License
1.05k stars 146 forks source link

after disconnecting the server from the internet it shuts down the DB then the whole app #251

Open 123mitnik opened 2 years ago

123mitnik commented 2 years ago

After following the documentation and setting up successfully the eventstore, here what happens if i disconnect from internet for about 2-3 minutes note: this happens on osx with the mentioned at the end deps.

first it shuts down its own DB, then the main DB and finally it terminates the whole app..

defmodule App.EventStore.Subscriber do
  use GenServer
  alias App.EventStore.EventStore
  alias App.Accounts

  def start_link(_args) do
    GenServer.start_link(__MODULE__, [])
  end

  def received_events(subscriber) do
    GenServer.call(subscriber, :received_events)
  end

  def init(events) do
    # Subscribe to events from all streams
    {:ok, subscription} =
      EventStore.subscribe_to_all_streams("topic_subscription", self())

    {:ok, %{events: events, subscription: subscription}}
  end

  # Successfully subscribed to all streams
  def handle_info({:subscribed, subscription}, %{subscription: subscription} = state) do
    {:noreply, state}
  end

  # Event notification
  def handle_info({:events, events}, state) do
    %{events: existing_events, subscription: subscription} = state
...........

[debug] Subscription "topic_subscription"@"$all" subscriber #PID<0.818.0> down due to: :shutdown [debug] Subscription "topic_subscription"@"$all" has no subscribers, shutting down [debug] Monitored server Postgrex.Notifications terminate due to: :shutdown [debug] Monitored server Postgrex terminate due to: :shutdown [debug] Monitored server Postgrex terminate due to: :shutdown

Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]
      {:phoenix, "~> 1.6.6"},
      {:phoenix_ecto, "~> 4.4"},
      {:eventstore, "~> 1.3"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},