readme.md
# Elixir Unix Signal Helper
After you've added the dependency:
```elixir
def deps do
[{:signalex, "~> 0.0.1"}]
end
```
You can create your signal handler:
```elixir
defmodule MyProject.SignalHandler do
use Signalex
def handle_event(:sigterm, state) do
# do some cleanup or whatever
{:ok, state}
end
end
```
If you want to handle a signal other than `sigusr1`, `sigquit` and `sigterm`, you'll need to list it explicitly:
```elixir
defmodule MyProject.SignalHandler do
use Signalex, handle: [:sigusr2, :sigalrm]
...
end
```
Start the handler:
```elixir
:ok = MyProject.SignalHandler.start()
```
Since the module is only executed once, on termination, there's little point in supervision.
As far as I can tell, there's no way to prevent the application from shutting down (which is part of the reason why there's no test for this). But you can execute code to do cleanup or whatever and delay termination until your handler exits.