moving restarter application into pleroma repo
This commit is contained in:
parent
7c6e5c541d
commit
91ea3ed82c
4 changed files with 58 additions and 1 deletions
28
restarter/lib/pleroma.ex
Normal file
28
restarter/lib/pleroma.ex
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
defmodule Restarter.Pleroma do
|
||||
use GenServer
|
||||
|
||||
def start_link(_) do
|
||||
GenServer.start_link(__MODULE__, [], name: __MODULE__)
|
||||
end
|
||||
|
||||
def init(_), do: {:ok, %{}}
|
||||
|
||||
def handle_info(:after_boot, %{after_boot: true} = state), do: {:noreply, state}
|
||||
|
||||
def handle_info(:after_boot, state) do
|
||||
restart(:pleroma)
|
||||
{:noreply, Map.put(state, :after_boot, true)}
|
||||
end
|
||||
|
||||
def handle_info({:restart, delay}, state) do
|
||||
Process.sleep(delay)
|
||||
restart(:pleroma)
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
defp restart(app) do
|
||||
:ok = Application.ensure_started(app)
|
||||
:ok = Application.stop(app)
|
||||
:ok = Application.start(app)
|
||||
end
|
||||
end
|
||||
8
restarter/lib/restarter.ex
Normal file
8
restarter/lib/restarter.ex
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
defmodule Restarter do
|
||||
use Application
|
||||
|
||||
def start(_, _) do
|
||||
opts = [strategy: :one_for_one, name: Restarter.Supervisor]
|
||||
Supervisor.start_link([Restarter.Pleroma], opts)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue