making ejabberd log to (r)syslog w/ daemontools
ESL Developer Blog - - June 24, 2009Having all logs in one place and a service which automatically is in charge of keeping a specific service running (e.g. ejabberd) is really nice to have. Forget about cronjobbed Scripts which check your service. daemontools is the one we use for this “always on” applications. You can download it here.
Installing daemontools is really simple on debian. You just create an Installation Script which sets up the files the supervise instance later uses to control your service. Save the following script to install_ejabberd_svc.sh and make it executable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #!/bin/bash
# v2009-04-09 tp@turtle-entertainment.de
# ejabberd and daemontools
#
echo STARTING EJABBERD WITH DAEMONTOOLS
# see
# http://cr.yp.to/daemontools/svc.html
# http://cr.yp.to/daemontools/softlimit.html
# http://www.kdegraaf.net/supervise.html
#
SERVICEDIR="/etc/service"
SERVICE="ejabberd
# No svc should be running, but to make sure we let it die first
svc -d ${SERVICEDIR}/${SERVICE} &> /dev/null
test -d && rm -rf ${SERVICEDIR}/${SERVICE}
mkdir -p ${SERVICEDIR}/${SERVICE}
test -f && rm -f ${SERVICEDIR}/${SERVICE}/run
test -f && rm -f ${SERVICEDIR}/${SERVICE}/tmprun
cat > ${SERVICEDIR}/${SERVICE}/tmprun <<EOF
#!/bin/sh
exec 2>&1
sleep 3
exec /opt/ejabberd/server/sbin/ejabberdctl start
EOF
chmod 755 ${SERVICEDIR}/${SERVICE}/tmprun
mv -f ${SERVICEDIR}/${SERVICE}/tmprun ${SERVICEDIR}/${SERVICE}/run
# Create log Pipe
mkdir -p ${SERVICEDIR}/${SERVICE}/log
chmod 1755 ${SERVICEDIR}/${SERVICE}/log
test -f && rm -f ${SERVICEDIR}/${SERVICE}/log/run
test -f && rm -f ${SERVICEDIR}/${SERVICE}/log/tmprun
cat > ${SERVICEDIR}/${SERVICE}/log/tmprun <<EOF
#!/bin/sh
exec env - PATH="/usr/bin" logger -p local5.err -t EJABBERD
EOF
chmod 755 ${SERVICEDIR}/${SERVICE}/log/tmprun
mv -f ${SERVICEDIR}/${SERVICE}/log/tmprun ${SERVICEDIR}/${SERVICE}/log/run |
Now you just need to run this script and install the daemontools-run package under debian. This automatically uses the just created structure and starts ejabberd with logging stdout to logger. Keep in mind that every programm you run under daemontools must run in foreground.
1 | aptitude install daemontools-run |
Thats it!
If you want to use rsyslog just setup your rsyslog.conf for redirecting local5.err to your rsyslogserver
1 | local5.err @10.10.0.99:514 |
Categories: Blogs ESL Developer Blog
Comments
No comments so far, you could be the first.Add comment
Erlang on Twitter
» despenjahatdos (Jon champion): Eits jangan salah begini2 saya titisan dewa erlang RT @yolapitalokaa: Yg ngepost twit kyknya jg lg galau drtd ... http://t.co/QfCyVSIl
» erlangtriaji (erlang triaji ): Sini sun ahahaha RT @Encays: Udah udah, lo berduaan aja RT @revianh: Kepooo! RT @erlangtriaji: Hadir RT @Encays: Udah, sama erlang aj
» Encays (antarif cahyadi): Menjepit RT @erlangtriaji: Tegang! RT @revianh: Kepooo! RT @erlangtriaji: Hadir RT @Encays: Udah, sama erlang aja RT @revianh
» erlangtriaji (erlang triaji ): Tegang! RT @revianh: Kepooo! RT @erlangtriaji: Hadir RT @Encays: Udah, sama erlang aja RT @revianh: Nanggepnya lama banget
» Encays (antarif cahyadi): Udah udah, lo berduaan aja RT @revianh: Kepooo! RT @erlangtriaji: Hadir RT @Encays: Udah, sama erlang aja RT @revianh: Nanggepnya lama
» revianh (Revian Hermansyah): Kepooo! RT @erlangtriaji: Hadir RT @Encays: Udah, sama erlang aja RT @revianh: Nanggepnya lama banget -_-
» erlangtriaji (erlang triaji ): Hadir RT @Encays: Udah, sama erlang aja RT @revianh: Nanggepnya lama banget -_-
» Encays (antarif cahyadi): Udah, sama erlang aja RT @revianh: Nanggepnya lama banget -_-
» mshiba64 (Masami Shibatani): Erlangではシリアライズはterm_to_binaryというBuilt-in-functionで実行される。画像データもErlangで扱われるいくつかのTermも全てBinary型に可逆変換できる。
» tomohikoseven (tomohiko nagase): 更新した。|andreのブログ: Erlang avl tree insert を作った : http://t.co/4uBqenSw
Statistics
Number of aggregated posts: 10454
Number of comments: 1392
Most recent article: January 31, 2012
Latest comments
» nobelboy on OpaDo Data Storage: Feel free to add some Qs here or contact me offline, and I will see what I can work into…
» darrensy on The Twisted Matrix: This has been a great idea you have shared. covers for kindle
» jony on Principle Software Engineer at LonoCloud (Full-time): That provides will become a internet marketer of little kinds of expert methods developers developing strategy using Erlang/OTP. There will…