This application waits for a flag file to appear, then initiates a graceful shutdown
by calling :init.stop()
. See the Erlang man page.
The purpose is to allow new releases of the app to be deployed and the app
restarted without the deployer needing permissions to run e.g. systemctl restart
.
If available in Hex, the package can be installed
by adding shutdown_flag
to your list of dependencies in mix.exs
:
def deps do
[
{:shutdown_flag, "~> 0.1.0"}
]
end
config :shutdown_flag,
flag_file: "/tmp/shutdown_flag/restart.txt",
check_delay: 10_000
flag_file
specifies the path to the flag file. Default is /tmp/shutdown_flag/restart.txt
.
Note that the user account that the app is running under needs to have file system permissions
to delete this file, or there will be a restart loop. The app will shutdown, then get restarted,
see the file, then shutdown, get restarted, and so on.
check_delay
specfies how often, in milliseconds, to check for the file. Default is 10s.
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/shutdown_flag.