Better restart logic of rabbitmq and ejabberd