[ejabberd] ejabberd restart takes alot of time

Badlop badlop at gmail.com
Fri Apr 23 01:37:45 MSD 2010

2010/3/23 Pablo Platt <pablo.platt at yahoo.com>:

Yes, a month has passed since you first asked,
but this question is timeless, so it always makes sense to answer it.

> I needed to add a vhost so I edited the ejabberd.cfg file and stopped
> ejabberd with:
> sudo ejabberdctl stop
> ejabberdctl status showed that ejabberd is still running so I killed the
> process.

That probably left the disk files of some tables in an unstable way.

> I cleared the log folder so I can see new issues.
> Then I started ejabberd but status says:
> The node ejabberd at localhost is starting with status: started
> ejabberd is not running in that node
> Check for error messages: //var/log/ejabberd/ejabberd.log

> In the log folder I only saw erlang.log that contained no errors.
> After several mintues ejabberd run properly without me doing anything.
> Is it possible that it took a long time because ejabberd needed to repair
> mnesia tables?
> Is there a way to tell that ejabberd is doing this?

Yes, probably Mnesia was fixing the tables that were left unclosed before.

For example, in a large database, if I kill beam, the next restart I find
in erlang.log (in older ejabberd releases was called sasl.log):

=PROGRESS REPORT==== 22-Apr-2010::23:20:27 ===
          supervisor: {local,kernel_safe_sup}
             started: [{pid,<0.77.0>},
dets: file "/var/lib/ejabberd/offline_msg.DAT" not properly closed,
repairing ...
dets: file "/var/lib/ejabberd/vcard.DAT" not properly closed,
repairing ...
dets: file "/var/lib/ejabberd/pubsub_item.DAT" not properly closed,
repairing ...

=PROGRESS REPORT==== 22-Apr-2010::23:20:51 ===

As you can see, starting Mnesia and recovering some tables took 24 seconds.

Then stopped, and started again. Those messages aren't displayed again.
But of course loading the Mnesia database from disk files to memory
takes some time.
In this case it was just 11 seconds:

=PROGRESS REPORT==== 22-Apr-2010::23:22:13 ===
         application: mnesia
          started_at: ejabberd at galleta

=PROGRESS REPORT==== 22-Apr-2010::23:22:24 ===

> How can I stop ejabberd without needing long restart time?

As you already did the first time
  ejabberdctl stop
(or in your case, with sudo).
But be patient while Mnesia saves to disk and closes the files properly

You can also try the more complete, slow, verbose and graceful:
$ ejabberdctl stop_kindly 10 \"The server will stop in 10 seconds\"
[1/7 0s] Stopping ejabberd port listeners... ok
[2/7 0s] Sending announcement to connected users... ok
[3/7 0s] Sending service message to MUC rooms... ok
[4/7 0s] Waiting 10 seconds... ok
[5/7 10s] Stopping ejabberd... ok
[6/7 15s] Stopping Mnesia... stopped
[7/7 15s] Stopping Erlang node... ok

In my case Mnesia stopped very fast (less than 1 second) because I had
just started it and there was nothing to write in disk.


More information about the ejabberd mailing list