-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up parent code_sync artifacts on pool shutdown
- Loading branch information
1 parent
439752e
commit e64ad84
Showing
4 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule FLAME.Pool.Cleaner do | ||
@moduledoc false | ||
use GenServer | ||
|
||
def start_link(opts) do | ||
GenServer.start_link(__MODULE__, opts, name: Keyword.fetch!(opts, :name)) | ||
end | ||
|
||
def watch_path(server, path) do | ||
GenServer.call(server, {:watch, path}) | ||
end | ||
|
||
def list_paths(server) do | ||
GenServer.call(server, :list) | ||
end | ||
|
||
def init(_opts) do | ||
Process.flag(:trap_exit, true) | ||
{:ok, %{paths: []}} | ||
end | ||
|
||
def handle_call({:watch, path}, _from, state) do | ||
{:reply, :ok, %{state | paths: [path | state.paths]}} | ||
end | ||
|
||
def handle_call(:list, _from, state) do | ||
{:reply, state.paths, state} | ||
end | ||
|
||
def terminate(_reason, state) do | ||
for path <- state.paths, do: File.rm!(path) | ||
|
||
:ok | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters