amavis-user October 2010 archive
Main Archive Page > Month Archives  > amavis-user archives
amavis-user: Re: [AMaViS-user] How to run multiple instances of

Re: [AMaViS-user] How to run multiple instances of amavisd-new?

From: Mark Martinec <Mark.Martinec+amavis_at_nospam>
Date: Wed Oct 06 2010 - 15:03:43 GMT
To: amavis-user@lists.sourceforge.net

Peter,

> could anybody point me in the right direction? I want to run multiple
> instances of amavisd-new, each with its own configuration. I use Ubuntu
> 10.04 server with amavisd-new-2.6.4 (20090625). I tried to start
> amavisd-new with an alternative configuration file but that did not work
> because there are multiple configuration files in /etc/amavis/conf.d and
> I can't specify a directory.

As far as I can tell the Ubuntu and Debian ports of amavisd-new make
the following main change to amavisd:

-push(@config_files, '/etc/amavisd.conf') if !@config_files;
+if (!@config_files) {
+ @config_files = Amavis::Util::find_config_files('/usr/share/amavis/conf.d',
+ '/etc/amavis/conf.d');

which means that if an explicit option: -c <config-file> on a command
line is given, the defaults from conf.d/* will be ignored and only the
explicitly specified config files (one or more) will be used.

You can still inherit these by calling include_config_files()
(and possibly find_config_files) from your own config file if you like.

To run multiple instances, bear in mind that each instance must have
its own $pid_file, $lock_file, $db_home, its own set of port numbers
and/or a bind address ($inet_socket_port, $inet_socket_bind),
and its own $unix_socketname if in use.

It is convenient (but not necessary) to give each instance
its own program name (as seen in 'ps' and 'top') and syslog id:
  $myprogram_name = 'amavisd2';
  $syslog_ident = 'amavis2';
and possibly (but not necessarily) its own work directory:
  $TEMPBASE = "$MYHOME/tmp-am2";
  $ENV{TMPDIR} = $TEMPBASE;
and maybe its own smtp greeting:
  $smtpd_greeting_banner =
    '${helo-name} ${protocol} ${product} WHATEVER service ready';

If only a minority of settings differ between config files of each
instance, it may be more convenient to use the same config file
for all, and distinguish instances by an -i option on a command line.

amavisd-new-2.5.0 release notes:

- a new command line option -i, it takes one argument which can be any
  string (an instance/personality name), which is then made available to
  amavisd.conf in a variable $instance_name (intended to be read-only);
  code in amavisd does not assign any semantics to this argument and does
  not use it for any purpose, it is purely intended for administrator's
  use in amavisd.conf if desired; this simple mechanism may facilitate
  running multiple instances of amavisd using a single configuration file,
  or to choose at startup time between amavisd personalities using the
  same config file;

  A possible usage is to start a test instance of amavisd while a production
  amavisd is still running, and letting a test instance listen on its
  dedicated TCP port number. Each server instance needs its own pid and
  lock files, its own TCP port number or socket name, and its own $db_home
  (nanny, cache, agent) unless bdb usage is disabled. A working directory
  may be shared or kept separate.

  An example to put by the end of amavisd.conf:

  if ($instance_name eq 'test') {
    $log_level = 5;
    $sa_debug = 1;
    $max_servers = 1;
    $TEMPBASE = "$MYHOME/tmp-am2";
    $ENV{TMPDIR} = $TEMPBASE;
    $pid_file = "$MYHOME/home/amavisd2.pid";
    $lock_file = "$MYHOME/home/amavisd2.lock";
    $enable_db = 0;
    $inet_socket_port = [8888]; # listen on port 8888
  }

  Start a test instance:
    # amavisd -i test debug
  and submit a test message to it, e.g.:
    $ mini_sendmail -fpostmaster@example.net \
        -s127.0.0.1 -p8888 test@example.net <0.msg

Mark

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
 Please visit http://www.ijs.si/software/amavisd/ regularly
 For administrativa requests please send email to rainer at openantivirus dot org