-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for new relx directive that provides start/stop script hooks #445
Add support for new relx directive that provides start/stop script hooks #445
Conversation
1d74e09
to
b7084a7
Compare
Oh hm, this is great! I need to try this out and use it for my new cuttlefish provider. I'll hopefully merge it in today. |
@lrascao problem with this patch is the start hooks only run before |
right, i'll update the PR |
b7084a7
to
d306b5f
Compare
@tsloughter have you had a chance to try this out with cuttlefish? |
I haven't since your last update. |
d306b5f
to
4112358
Compare
exec "$@" -- ${1+$ARGS} | ||
[ "$POST_START_HOOK" ] && . "$POST_START_HOOK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem with this (and affects all of these) is that the post_start
event will either never be executed, or will only be executed when the release stops, which is obviously not desired for a post_start
event handler. I think the best way to do this is by backgrounding the task, executing the post_start
task, then waiting on the PID, instead of blocking on exec
. I'm using this approach right now in some work I'm doing in Mix, because I wanted to trap exit signals and cleanly shut down the VM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, so something like:
pre_start_hook
Pid = spawn (exec "$@" -- ${1+$ARGS})
post_start_hook
wait on Pid
did i understood correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've since updated the PR, it now sends the execs to background and waits on them after the post hook
4112358
to
de70895
Compare
de70895
to
09838d5
Compare
c51bc55
to
b18cd12
Compare
e72b79b
to
b31a951
Compare
b31a951
to
5775a01
Compare
e078582
to
15f0940
Compare
6082ee4
to
4572296
Compare
Move it next to console since it's mostly the same thing but with extra parameters.
1e14e04
to
4abbaa6
Compare
…ipt 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.
4abbaa6
to
3905d39
Compare
@tsloughter this is ready for review |
Looks great! Should we wait for +1's from @GoelDeepak and @saleyn ? |
yeah, let's wait a few days, they might have some improvement suggestions |
Yes, looks like a good idea. |
@tsloughter i guess it's good to merge |
New 'extended_start_script_hooks' directive that allows the developer to define six different hook 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:
(/var/run/<rel_name>.pid by default).
The hook scripts are invoked with the 'source' command, therefore they have access to all the variables in the start script.
These hook scripts apply only to
start
,stop
andupgrade/downgrade/install/uninstall
commands.The paths are relative to the start script, and the syntax is:
Possible use cases: