[ejabberd] High filesystem usage
Jim Wagner
jwagner at graffadmin.com
Fri Feb 12 01:18:17 MSK 2010
> On 10 February 2010 17:05, Matias <matiassurdi at gmail.com> wrote:
>
> Yes, as it seems that FreeBSD's newsyslog can't run commands after log
> rotation, I've setup a cron job one minute after the rotation to run
> that command.
>
> Thanks a lot!
>
>
I have a workaround for this limitation in newsyslog. Save the below
script as /usr/local/sbin/indirect-ejabberd, change the PID file in
/etc/newsyslog.conf to be /var/run/indirect-ejabberd, and create a
startup script to start /usr/local/sbin/indirect-ejabberd in the
background. I wrote it to be generic enough to modify easily for
anything that needs to execute a command from newsyslog instead of the
program responding to the HUP signal - just change the variables as you
desire.
Jim
PS - If you have trouble copying & pasting from e-mail, this same
script is shown in forum style at
http://forums.freebsd.org/showthread.php?t=11224
#!/usr/local/bin/bash
###############################################################################
#
#
# Shell script to allow a command to be executed upon receipt of a
signal. #
# Designed to allow newsyslog to execute a command for software that
either #
# does not have a PID file or does not respond to a SIG_HUP signal
and #
# requires an external command to reopen its log
file. #
#
#
###############################################################################
#
#
# Ruler's Common-Sense
License: #
#
#
# You may use this script however you want to, but I don't warrant it
to #
# be good for anything in particular, though it happens to work well
for #
# me. (I hate putting BS like this in, but I hate more being sued.)
If #
# you use this script, you must keep this license and credit to me in
it #
# in the form of this block, even if you modify it for your own use.
If #
# you want to send me money for it, fantastic! Send me a private
message #
# on the freebsd.org forums and I'll give you my PayPal address. :-)
Even #
# just a simple 'thank you' would be nice. If not, that's fine too.
All #
# hate mail/spam is sent directly to
/dev/null #
# - Jim, AKA
Ruler2112 #
#
#
###############################################################################
#
#
#
History:
#
#
#
# 2010-02-11 by Ruler2112 Wrote initial
version. #
# 2010-02-11 by Ruler2112 Released on freebsd.org
forums. #
#
#
###############################################################################
###############################################################################
# Variable Declaration
Section #
# Set these variables to customize this script's
behavior. #
###############################################################################
# What happens when a HUP signal is received.
HUP_ACTION="/usr/local/sbin/ejabberdctl reopen-log"
# How many seconds to pause between signal checks. This will be the
maximum
# amount of time between the time a signal is received and when the
associated
# action occurs. The lower this is, the more CPU time this script will use
# Higher values will decrease the amount of CPU power this script will
consume
# but also increases the likelihood of a significant wait betwwen the
sending
# of the signal and when the appropriate action is executed.
WAIT_TIME=3
# The name of a PID file that this script will generate. Use this in
# /etc/newsyslog.conf THIS SCRIPT WILL SILENTLY OVERWRITE THIS FILE,
# BE 100% CERTAIN THAT IT'S NOT AN IMPORTANT FILE!!! I recommend using
# something in /var/run and naming it indirect-<name> for safety.
MY_PID_FILE="/var/run/indirect-ejabberd"
###############################################################################
# !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
WARNING !!! #
###############################################################################
# This is the Beginning of the
Script #
#
#
# Do not change anything below this line unless you know what you're
doing! #
###############################################################################
/bin/echo $$ > "$MY_PID_FILE"
trap "$HUP_ACTION" SIGHUP
trap "/bin/rm -f \"$MY_PID_FILE\";exit 0" SIGINT SIGTERM
while true; do
/bin/sleep $WAIT_TIME
done
More information about the ejabberd
mailing list