MailScanner in foreground - use MailScanner with DJB's daemontools

Mariano Absatz mailscanner at LISTS.COM.AR
Sun May 30 20:32:59 IST 2004


Hi,

I developed a patch for MailScanner to add an option (in MailScanner.conf)
that allows it to run in foreground; that is, to not 'daemonize' itself.

This is useful when you have a tool to monitor a running process.

DJB's daemontools ( http://cr.yp.to/daemontools.html ) include such a tool,
and it's named supervise ( http://cr.yp.to/daemontools/supervise.html ).

I also know of HA clustering tools that require programs to run in foreground
in order to provide High Availability to it.

In http://baby.com.ar/MailScanner/RunInForeground I left a couple of patches
for versions 4.29.7-1 and 4.30.3-2 of MailScanner.

There are also a couple of subdirectories with the completely patched files.

The modified files are:
bin/MailScanner
lib/MailScanner/ConfigDefs.pl
etc/MailScanner.conf

The new option (added to the 'Advanced Settings' section of MailScanner.conf)
is:
Run In Foreground

The default is obviously 'no'

If you set this to 'yes', MailScanner will run in foreground, but not in
debug mode (if you also set 'Debug = yes' then this latter setting takes
precedence).

That is, the MailScanner main process will be a child of the launching
process (e.g. your shell session), and it will spawn up to 'MaxChildren'
children to do the actual job.

As a value added, MailScanner in this mode does some minimal logging to
STDOUT which you can see in your terminal or capture somehow.

I also added a couple of 'run' scripts to use with daemontools.

One is for actually running MailScanner and is in the MailScanner directory
itself (it requires that you run MailScanner in foreground).

The other one, in the 'log' subdirectory, is for logging the standard output
and standard error using multilog.

After patching MailScanner and installing daemontools, you can edit
MailScanner.conf and set 'Run In Foreground = yes'. You must stop MailScanner
and disable the standard /etc/rc.d/init.d/MailScanner startup script (which
would hang if MailScanner is run in foreground) with something like:
# chkconfig MailScanner off
Make sure both 'run' scripts are executable:
# chmod +x /opt/MailScanner/run /opt/MailScanner/log/run

and then:
# ln -s /opt/MailScanner /service

In a few seconds, MailScanner should be up and running.

You can monitor the new logging with:
# tail -f /opt/MailScanner/log/main/current | tai64nlocal

Please refer to http://cr.yp.to/daemontools.html for instructions on how to
properly use these tools.

I'll try to add an entry for this in the FAQ-O-Matic.

Regards.

--
Mariano Absatz
El Baby
----------------------------------------------------------
The Internet is mightier than the pen.

-------------------------- MailScanner list ----------------------
To leave, send    leave mailscanner    to jiscmail at jiscmail.ac.uk
Before posting, please see the Most Asked Questions at
http://www.mailscanner.biz/maq/     and the archives at
http://www.jiscmail.ac.uk/lists/mailscanner.html



More information about the MailScanner mailing list