Service to run and monitor OS processes.
- Define a elixir script module
Commander.Daemons
withget_spec
function which returns processes which should be running,
defmodule Commander.Daemons do
def get_spec() do
%{
sleep_500: %{
command: "sleep",
arg_list: ["500"],
options: []
}
}
end
end
- Configure the path of the elixir script containing the list of processes to run and monitor
Application.get_env(:commander, :daemons_config_file) # "/home/user/workspace/commander/daemon.exs"
- Lastly invoke
Commander.sync_config()
which will ensure that all processes returned byCommander.Daemons.get_spec()
are running. NOTE: Any process which are currently running but no longer returned byget_spec()
will be stopped.