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
» jkvor (Jacob Vorreuter): Erlang target systems and release handling http://jkvor.com/release-handling
» REDDITSPAMMOR (REDDITSPAMMOR): #reddit Joe Armstrong, the father of Erlang, finally publishes his library of Erlang code!: submitted by p… http://bit.ly/bfBhWR
#rulez
» rmdrimmie (Rob Drimmie): @JamieBeach And by wide variety I mean different syntaxes, conventions. Not c, c++ and obj-c, but c, ruby, lisp or php, python, erlang, etc.
» monadic (alexis richardson): @roidrage and at erlang factory ...
» tm_interesting (Thomas Buck): How Much Has Scala Influenced Erlang? http://functional-orbitz.blogspot.com/2010/03/how-much-has-scala-affected-erlang.html
» YCHackerNews (YC Hacker News): How Much Has Scala Influenced Erlang?: http: Comments: http:
» kicauan (kicauan): How Much Has Scala Influenced Erlang? - http://su.pr/81fsWx
» hntweets (Hacker News): How Much Has Scala Influenced Erlang?: http://bit.ly/9tE1uy Comments: http://bit.ly/darEqv
» hkrnws (hkrnws): How Much Has Scala Influenced Erlang? http://bit.ly/aiEnK5
» darachennis (darachennis): joearms elib1 - get it on github now #erlang
Statistics
Number of aggregated posts: 9911
Number of comments: 380
Most recent article: March 11, 2010
Latest comments
» Jens on Eleven Years of Erlang: Hi, The link to how you started with Erlang is broken. Regards, Jens
» Jeff Martens on It Made Sense in 1978: I agree that word size is machine specific, but it becomes language-specific once it’s in a language definition. In Java an …
» Adley on XP Day Suisse 2009: What a great post. What an inspiration for everyone who is asking ‘Where is all this stuff I’ve asked for?’ and …