Skip to content
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

Kill orphan epmd after ejabberdctl ping #4327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

catap
Copy link

@catap catap commented Dec 12, 2024

Here a trivial changes that cleanup an orphan epmd after ejabberdctl ping which migth be used inside some scripts to confirm that ejabberd is stop.

@badlop
Copy link
Member

badlop commented Dec 16, 2024

ejabberdctl ping which migth be used inside some scripts to confirm that ejabberd is stop.

"confirm that ejabberd is stop"? there's exactly a command to do that, ejabberdctl stopped :)

On the other hand, ping is used to confirm that ejabberd is running.

Why do you use ping instead of stopped for that purpose? Maybe it's possible to improve stopped.

@catap
Copy link
Author

catap commented Dec 16, 2024

@badlop I use ping as a way to check status of ejabberd in my rc script for OpenBSD. But rc in OpenBSD works like this: inside start and stop it does check to confirm that services is really stopped or started, see: https://github.com/openbsd/src/blob/master/etc/rc.d/rc.subr#L266-L292

@badlop
Copy link
Member

badlop commented Dec 16, 2024

I'm sorry, I don't understand what benefit ping provides that stopped lacks for checking if ejabberd is stopped.

I'm trying to understand the reason for using one method instead of the other, maybe there is some change that would improve stopped usefulness.

On the other hand, you may want to consider dropping epmd completely: did you know ejabberd can be started and administered without using epmd at all? Just enable ERL_DIST_PORT, see 30f1e28

in my rc script for OpenBSD

Do you mean this is your personal script? Or are you preparing changes for the OpenBSD upstream pakage?

@catap
Copy link
Author

catap commented Dec 16, 2024

@badlop let me rephase my phrase.

The rc script for OpenBSD looks like:

rc_start() {
	rc_exec "${daemon} ${daemon_flags} start \
		&& ${daemon} ${daemon_flags} started"
}

rc_check() {
	rc_exec "${daemon} ${daemon_flags} ping | grep -q pong"
}

rc_reload() {
	rc_exec "${daemon} ${daemon_flags} reload_config"
}

rc_stop() {
	rc_exec "${daemon} ${daemon_flags} stop \
		&& ${daemon} ${daemon_flags} stopped"
}

When someone calls rcctl start ejabberd it calls: rc_start and after that rc_check. The same happens for rcctl stop ejabberd: rc_stop and after that rc_check.

The rc system relays on rc_check to confirm that daemon really started or stopped.

Current script works well, with one exception it leaves orphan epmd after rcctl stop ejabberd.

@badlop
Copy link
Member

badlop commented Dec 20, 2024

Aha, now I understand the situation thanks!

Your script uses stopped to check it was stopped, and ping to double check this and any other start/stop operation. As any of those commands start epmd, then you would like to stop epmd after calling ping.

Is it reasonable to assume that some other people, instead of ping, may use other command like status, and then they will also request to call stop_epmd after whatever command they picked? Following that trend, we would call stop_epmd after each single call...

Alternatively, if you are worried about leaving epmd running, you could try my previous suggestion: don't use epmd at all:

On the other hand, you may want to consider dropping epmd completely: did you know ejabberd can be started and administered without using epmd at all? Just enable ERL_DIST_PORT, see 30f1e28

If you setup the option ERL_DIST_PORT in ejabberdctl.cfg, epmd will not be started at all. Of course all the ejabberdctl features work perfectly, using that port number instead of calling epmd.

@catap
Copy link
Author

catap commented Dec 20, 2024

Is it reasonable to assume that some other people, instead of ping, may use other command like status, and then they will also request to call stop_epmd after whatever command they picked? Following that trend, we would call stop_epmd after each single call...

What seems resanable, because each command my run epmd if it needed.

Alternatively, if you are worried about leaving epmd running, you could try my previous suggestion: don't use epmd at all:

On the other hand, you may want to consider dropping epmd completely: did you know ejabberd can be started and administered without using epmd at all? Just enable ERL_DIST_PORT, see 30f1e28

If you setup the option ERL_DIST_PORT in ejabberdctl.cfg, epmd will not be started at all. Of course all the ejabberdctl features work perfectly, using that port number instead of calling epmd.

Yep, this is current solution. But I've switched to it not because I'm worried about running epmd.

Here different point: epmd may be run as system services, and stopped may killls it, if ejabberd the last application which uses it. To avoid this, I've migrated everything to non-epmd setup.

BTW, feel free to close this PR if you think that here no need for this changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants