aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorAlexey Lebedeff <[email protected]>2016-03-29 20:30:22 +0300
committerAlexey Lebedeff <[email protected]>2016-03-29 20:30:22 +0300
commit16b921ad1c847ba0754adc10d2d45b17973dcd19 (patch)
tree608a382247d87fd6ad92f3b48063148ab272c20d /erts
parent523e048754f5086a6cc4fd9a250e1b495fc5b9b8 (diff)
downloadotp-16b921ad1c847ba0754adc10d2d45b17973dcd19.tar.gz
otp-16b921ad1c847ba0754adc10d2d45b17973dcd19.tar.bz2
otp-16b921ad1c847ba0754adc10d2d45b17973dcd19.zip
Don't send unasked for systemd notifications
Suppose we have some erlang system that uses systemd unit with Type=notify - so this should send startup confirmation itself. But if systemd-enabled epmd will be started as a first step of that system startup, empd startup confirmation will be misinterpeted by systemd. And our erlang service will be considered 'ready' to early. Also this will interefere with systemd MAINPID detection: systemd will be monitoring `epmd` process instead of `beam` one. For example, rabbitmq works around this issue by starting epmd using separate short-lived beam process, with NOTIFY_SOCKET environment variable reset - only in this way we could be sure that epmd will not interfere with rabbit startup sequence. This patch disables indiscriminate confirmation sending, and does it only when it was explicitly asked to do so.
Diffstat (limited to 'erts')
-rw-r--r--erts/epmd/src/epmd.c6
-rw-r--r--erts/epmd/src/epmd_srv.c8
2 files changed, 9 insertions, 5 deletions
diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c
index 5513cb2d7e..4740ce8534 100644
--- a/erts/epmd/src/epmd.c
+++ b/erts/epmd/src/epmd.c
@@ -592,8 +592,10 @@ void epmd_cleanup_exit(EpmdVars *g, int exitval)
free(g->argv);
}
#ifdef HAVE_SYSTEMD_DAEMON
- sd_notifyf(0, "STATUS=Exited.\n"
- "ERRNO=%i", exitval);
+ if (g->is_systemd){
+ sd_notifyf(0, "STATUS=Exited.\n"
+ "ERRNO=%i", exitval);
+ }
#endif /* HAVE_SYSTEMD_DAEMON */
exit(exitval);
}
diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c
index e1bac99ef9..59d59ad0f7 100644
--- a/erts/epmd/src/epmd_srv.c
+++ b/erts/epmd/src/epmd_srv.c
@@ -452,9 +452,11 @@ void run(EpmdVars *g)
num_sockets = bound;
#ifdef HAVE_SYSTEMD_DAEMON
}
- sd_notifyf(0, "READY=1\n"
- "STATUS=Processing port mapping requests...\n"
- "MAINPID=%lu", (unsigned long) getpid());
+ if (g->is_systemd) {
+ sd_notifyf(0, "READY=1\n"
+ "STATUS=Processing port mapping requests...\n"
+ "MAINPID=%lu", (unsigned long) getpid());
+ }
#endif /* HAVE_SYSTEMD_DAEMON */
dbg_tty_printf(g,2,"entering the main select() loop");