Running ejabberd as a user

Hi,
I've got ejabberd working fine when I run it as root.

My script for doing that looks like this:

erl -pa /var/lib/ejabberd/ebin \
-sname ejabberd \
-s ejabberd \
-ejabberd config \"/etc/ejabberd/ejabberd.cfg\" \
log_path \"/var/log/ejabberd/ejabberd.log\" \
-sasl sasl_error_logger \{file,\"/var/log/ejabberd/sasl.log\"\} \
-mnesia dir \"/var/lib/ejabberd/spool\" \
-detached

This works fine, but I followed the instructions at http://www.ejabberd.im/tuto-install-ejabberd which suggested that I create a user for ejabberd and run it as that. I have created a user called ejabberd and a group called jabber (to which ejabberd belongs) and modified my startup script to this:

su ejabberd -c "erl -pa /var/lib/ejabberd/ebin \
-sname ejabberd \
-s ejabberd \
-ejabberd config \"/etc/ejabberd/ejabberd.cfg\" \
log_path \"/var/log/ejabberd/ejabberd.log\" \
-sasl sasl_error_logger \{file,\"/var/log/ejabberd/sasl.log\"\} \
-mnesia dir \"/var/lib/ejabberd/spool\" \
-detached"

And although when I check the status of the server with "ejabberdctl ejabberd@myhost status", it tells me that it's running, I can't access the server from my client (Psi) on another machine. I tried enabling the XML console to see what the error was, but nothing got printed. The error in the dialog that I got was: "There was an error communicating with the Jabber server. Details: connection Error: Unable to connect to server".

Any ideas?
Raj.

Re: Running ejabberd as a user

Hi Raj,
You schould check the owner of your Mnesia directory files. If they got created using ejabberd running as root they are owned by root, and user ejabberd that runs server now, cannot access them. chown the files to ejabberd and that schould make it.

Regards,
Tomaso.

Hi Tomaso,I tried doing

Hi Tomaso,
I tried doing that without any luck :(. I also changed the permissions of the ejabberd.cfg directory and the log file with the same problem. I ran my script without the -detached option and got this error:

application_controller: syntax error before: '/': /etc/ejabberd/ejabberd.cfg

I don't understand this since it works fine when I run as root.

The only uncommented lines with a '/' in them in my ejabberd.cfg file are in the listen section:

{5222, ejabberd_c2s, [{access, c2s}, shaper, c2s_shaper},
                      starttls, {certfile, "./ssl.pem"}]},
{5223, ejabberd_c2s, [access, c2s},
                      tls, {certfile, "./ssl.pem"}]}

I can't find an ssl.pem file anywhere.

Re: Running ejabberd as a user Try try to follow this

Hi,
Try try to follow this tutorial: http://www.ejabberd.im/tuto-install-ejabberd
to create the certificates. Then change the location of ssl.pem in your config to the proper one and you will be able to check if this solves the problem.

Sorted (sort of)

Hi Tomosa,
I've got it more or less sorted out now, although it's still a weird one. In the end what seemed to be the problem was epmd running as a daemon (/usr/local/lib/erland/erts-5.4.6/bin/epmd -daemon). This process was owned by root and wasn't getting shut down when I stopped ejabberd. After I killed that, logged in as the ejabberd user and ran the command, it ran successfully.

Weirdly, it still won't let me run my script with su ejabberd -c "...", but if I actually login as the user and run the same "...", it works fine!

Still, I'm happy with what I've got, and I've got the MSN transport installed and working now too, so as long as I remember to kill epmd when I stop ejabberd and su ejabberd when I want to restart it, I'll be fine :-). Thanks very much for your help, though).

Cheers,
Raj.

Syndicate content