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
» j1ee (j1ee): erlang weirdness http://damienkatz.net/2008/03/what_sucks_abou.html
» b_architect (Weera Kasetsin): หล่อขึ้นทุกวันนะครับพี่ :) >> ฝึกเขียน erlang ส่วน web service client. (via @pphetra)
» pphetra (pphetra): ฝึกเขียน erlang ส่วน web service client.
» Y_Hirano (Hirano): Erlangとかはどうなんだろう。ちらっと概要を流し読みした程度だけど。
» yxwlmxy (Eric May): RT @KrzyCube: RT @FrancescoC: Erlang and Scala might make it in the TIOBE top 20 index next month. http://bit.ly/aZVVt6 Great news!
» timocramer (Timo Cramer): Ist es mein objektorientiert-imperatives Stockholm-Syndrom oder was finde ich an #Erlang so schwierig?
» krzycube (Xihe Yu | 方块): RT @FrancescoC: Erlang and Scala might make it in the TIOBE top 20 index next month. http://bit.ly/aZVVt6 Great news!
» dhinojosa (Daniel Hinojosa): http://short.to/16h1r Scratch, Erlang, Scala, and JavaFX may enter the Tiobe top 20 next month.
» rafik (Rafik): @uwiger thank you I want to work on erlang, I am newcomer and I am doing research in wireless sensor networks,
» shouta65 (勇気): …!?:ふぁぼったー / takkkun : っ http://bit.ly/7Ryln5 最初に挙げられている4つの特徴がちょうどいいと思ったからさ! RT @shouta65: Erlangって面白いのかな。てかなん http://bit.ly/b8nvBe
Statistics
Number of aggregated posts: 9882
Number of comments: 326
Most recent article: February 04, 2010
Latest comments
» Amar Montreal on My Google Wave Client: Very interesting as well as informative post.Thanks for providing for us.I read your article with my pleasure. Jumping Castle …
» Jhonson miami on My Google Wave Client: Its a nice post regarding law and its values.I think its necessary to each and individual to follow the law and …
» Jhonson miami on My Google Wave Client: Thanks for taking the time to post such a detailed and informative article. It has given me a lot of inspiration …