Boot Hooks¶
Boot hooks are scripts which execute pre/post to events that occur in the run control script.
Events¶
pre_configure
, occurs beforeREPLACE_OS_VARS
triggers replacement, and before any generated files are generatedpost_configure
, ocurrs after environment variable replacement and after generated files are generatedpre_start
, occurs before the release is startedpost_start
, occurs right after the release is startedpre_stop
, occurs after a request to stop the release is issued, but before the release is stoppedpost_stop
, occurs after the release is stopped
Example Usage¶
Given a config like the following:
1 2 3 4 5 6 7 8 9 10 | use Mix.Releases.Config environment :default do set pre_start_hook: "rel/hooks/pre_start" set post_start_hook: "rel/hooks/post_start" end release :myapp do set version: current_version(:myapp) end |
And the two hook scripts under rel/hooks
:
1 2 | # pre_start echo "we're starting!" |
1 2 | # post_start echo "we've started!" |
When you build your release, and run it, you’ll see something like the following:
1 2 3 4 5 | > _build/dev/rel/myapp/bin/myapp foreground we're starting! ...snip... we've started! ...snip... |
You have access to anything defined in the run control script environment, see Shell Scripts for details.