Ghoul v0.1.0 Ghoul
Link to this section Summary
Functions
Prevents a Ghoul from executing reap_in
or on_death
actions
Cancel a pending reap
Gets the current state of a Ghoul worker
Instruct the ghoul to kill the process after a delay. Each time this method is
called for a process, previous reap_in
directives are canceled. This lets
the Ghoul act as a deadman switch for a process, killing it should it fail to
progress in an expected manner
Sets the current state of a Ghoul worker
Summon a Ghoul to watch a process. When the pid terminates, the Ghoul will
execute the function in the on_death
option, passing in the process_key
,
the reason
the pid exited, and the current ghoul_state
Time until a process is reaped
Link to this section Functions
Prevents a Ghoul from executing reap_in
or on_death
actions.
Parameters
process_key
- theprocess_key
of the Ghoul to terminate
Cancel a pending reap.
Parameters
process_key
- theprocess_key
of the Ghoul to prevent termination
Gets the current state of a Ghoul worker.
Parameters
process_key
- theprocess_key
of the Ghoul to terminate
Instruct the ghoul to kill the process after a delay. Each time this method is
called for a process, previous reap_in
directives are canceled. This lets
the Ghoul act as a deadman switch for a process, killing it should it fail to
progress in an expected manner.
Parameters
process_key
- theprocess_key
of the Ghoul to terminatereason
- the reason to pass toProcess.exit/2
delay_ms
- how long to wait until reaping the process. Any
Sets the current state of a Ghoul worker.
Parameters
process_key
- theprocess_key
of the Ghoul to terminatenew_state
- the new value to use as theghoul_state
Summon a Ghoul to watch a process. When the pid terminates, the Ghoul will
execute the function in the on_death
option, passing in the process_key
,
the reason
the pid exited, and the current ghoul_state
.
Parameters
process_key
- How this pid should be known to Ghoul. Will be passed to theon_death
function as the first parameter.opts
- a keyword list or map with the following options::pid
- which pid to have the Ghoul stalk. Defaults to the calling pid.:on_death
- a function to be executed after the process dies. Defaults tonil
, and nothing will be executed. Expects 3-arity function, to be called asfun.(process_key, exit_reason, ghoul_state)
by the Ghoul.:initial_state
- the initialghoul_state
for this worker. Defaults tonil
. Theghoul_state
will be passed to theon_death
function as the third parameter, and can be queried usingGhoul.get_state/1
and changed usingGhoul.set_state/2
Time until a process is reaped.
Parameters
process_key
- theprocess_key
of the Ghoul to query