Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Support shutdown schedule for the Sqlitex.Server process after inactivity #91

Open
vinaya-procore opened this issue Oct 30, 2019 · 1 comment

Comments

@vinaya-procore
Copy link

Having a long running Sqlitex.Server process is awesome. What if I have N number of sqlite files in my project, and I want to start a process per file. Since I will have N processes running, I will want any process that has not been queried for a certain time, say 10 minutes, to be automatically shutdown.

Something like:

def init({state, timeout}) do
  Process.send_after(self(), :shutdown, timeout)
  {:ok, []}
end

def handle_info(:shutdown, _state) do
  exit(:normal)
  {:noreply, []}
end

Thanks

@ConnorRigby
Copy link
Member

this could be implemented by doing something like:

def init({state, timeout}) do
  {:ok, [], timeout}
end

def handle_info(:timeout, _state) do
   {:stop, :normal, state}
end

I'll have to think about the implications of this in the context of the ecto adapter

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants