aboutsummaryrefslogtreecommitdiffstats
path: root/priv/templates/builtin_hook_pid
diff options
context:
space:
mode:
authorLuis Rascao <[email protected]>2016-11-05 22:22:19 +0000
committerLuis Rascao <[email protected]>2016-11-12 23:59:07 +0000
commit3905d39d180efe125b9ef5351d1c3b27a3f825b0 (patch)
treeccfbd1bef3f2e3e2fc0b21bc2652b5a9132d1ff9 /priv/templates/builtin_hook_pid
parentad6193884f09d29c7402de45214817dc195f5c6d (diff)
downloadrelx-3905d39d180efe125b9ef5351d1c3b27a3f825b0.tar.gz
relx-3905d39d180efe125b9ef5351d1c3b27a3f825b0.tar.bz2
relx-3905d39d180efe125b9ef5351d1c3b27a3f825b0.zip
Add support for new relx directive that provides start/stop shell script hooks
New 'extended_start_script_hooks' directive that allows the developer to define six different hook shell scripts to be invoked at pre/post start/stop/install upgrade phases. Besides these custom defined scripts, other types of builtin scripts are also available, these offer pre-packaged functionality that can be used directly, they are: pid - writes the beam pid to a configurable file location (/var/run/<rel_name>.pid by default). wait_for_vm_start - waits for the vm to start (ie. when it responds to pings) wait_for_process - waits for a configurable name to appear in the erlang process registry The hook scripts are invoked with the 'source' command, therefore they have access to all the variables in the start script.
Diffstat (limited to 'priv/templates/builtin_hook_pid')
-rw-r--r--priv/templates/builtin_hook_pid12
1 files changed, 12 insertions, 0 deletions
diff --git a/priv/templates/builtin_hook_pid b/priv/templates/builtin_hook_pid
new file mode 100644
index 0000000..0151631
--- /dev/null
+++ b/priv/templates/builtin_hook_pid
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# loop until the VM starts responding to pings
+while ! $(relx_nodetool "ping">/dev/null)
+do
+ sleep 1
+done
+
+# get the beam pid and write it to the file passed as
+# argument
+PID="$(relx_get_pid)"
+echo $PID > $1