-
Notifications
You must be signed in to change notification settings - Fork 77
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
Feature: Let ejabberd startup fail if either CTL_ON_CREATE or CTL_ON_START fail #97
Comments
Ok, I wrote a small patch that seems to do the trick, at least in my local testing:
Now it should be checked in real circumstances, in a container. diff --git a/.github/container/ejabberdctl.template b/.github/container/ejabberdctl.template
index 1f4d902ec..84969f7ee 100755
--- a/.github/container/ejabberdctl.template
+++ b/.github/container/ejabberdctl.template
@@ -283,6 +283,12 @@ post_waiter_loop()
TAIL=${LIST#* ; }
echo ":> ejabberdctl $HEAD"
$0 $HEAD
+ ctlstatus=$?
+ if [ $ctlstatus -ne 0 ] ; then
+ echo ":> FAILURE in command '$HEAD' !!! Stopping ejabberd..."
+ $0 halt > /dev/null
+ exit $ctlstatus
+ fi
[ "$HEAD" = "$TAIL" ] || post_waiter_loop $TAIL
}
diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl
index 443d8164e..c84648532 100644
--- a/src/ejabberd_admin.erl
+++ b/src/ejabberd_admin.erl
@@ -116,6 +116,10 @@ get_commands_spec() ->
desc = "Stop ejabberd gracefully",
module = ?MODULE, function = stop,
args = [], result = {res, rescode}},
+ #ejabberd_commands{name = halt, tags = [server],
+ desc = "Halt ejabberd with status code 1",
+ module = ejabberd, function = halt,
+ args = [], result = {res, rescode}},
#ejabberd_commands{name = restart, tags = [server],
desc = "Restart ejabberd gracefully",
module = ?MODULE, function = restart, The patch adds a new command 'halt' that should return status code 1, I hope that helps to raise awareness that something went wrong. Alternatively, instead of
it could simply say
and the new halt command wouldn't be needed. |
yes, that works well! |
Also merged in ejabberd upstream repository for the |
Some configurations rely on the success of the two configurations
CTL_ON_CREATE
orCTL_ON_START
.Obviously some
ejabberdctl
cmds likeregister
orstatus
do not harm, if they aren't successful, but still a configuration may rely on them to be successful.Others like
join_cluster
may be more problematic, as a configuration may rely on a successful cluster join, but ejabberd would only report an error, if it fails and continue being up. In this case a startup failure due toCTL_ON_CREATE
orCTL_ON_START
failure would at least trigger the attention on logging tools in regard of continuous restarts or whatever.The text was updated successfully, but these errors were encountered: