trAvis - MANAGER
Edit File: smtpauth-manager
#!/usr/bin/perl eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; # not running under some shell # -*- coding: utf-8; mode:cperl -*- use strict; use warnings; use English; use POSIX; use IO::File; use Sys::Syslog; use Milter::SMTPAuth; use Milter::SMTPAuth::Utils; use Milter::SMTPAuth::Config; my $options = Milter::SMTPAuth::Config::ManagerConfig->new_with_options(); my $pid_file = sprintf( "%s/pid", $options->rundir() ); my $filter_socket = sprintf( "unix:%s/filter.sock", $options->rundir() ); my $logger_socket = sprintf( "unix:%s/log-collector.sock", $options->rundir() ); my $log_file = sprintf( "%s/stats.log", $options->logdir() ); openlog( 'smtpauth-manager', 'pid,nowait', 'mail' ); syslog( 'info', 'starting manager' ); my @log_collector_arguments = ( '--recv_address', $logger_socket, '--log', $log_file, '--threshold', $options->threshold(), '--period', $options->period(), '--max_messages', $options->max_messages(), '--foreground', ); if ( $options->auto_reject() ) { push( @log_collector_arguments, '--auto_reject' ); } if ( $options->geoip_v4() ) { push( @log_collector_arguments, '--geoip_v4', $options->geoip_v4() ); } if ( $options->geoip_v6() ) { push( @log_collector_arguments, '--geoip_v6', $options->geoip_v6() ); } if ( $options->alert_email() ) { push( @log_collector_arguments, '--alert_email', '--alert_mailhost', $options->alert_mailhost(), '--alert_port', $options->alert_port(), '--alert_sender', $options->alert_sender() ); foreach my $recipient ( @{ $options->alert_recipient() } ) { push( @log_collector_arguments, '--alert_recipient', $recipient ); } } my @filter_arguments = ( '--listen_address', $filter_socket, '--logger_address', $logger_socket, '--max_children', $options->max_children(), '--max_requests', $options->max_requests(), '--foreground', ); my $manager = new Milter::SMTPAuth( processes => [ new Milter::SMTPAuth::Child( command => 'smtpauth-log-collector', arguments => \@log_collector_arguments, signal_stop => 10, # SIGUSR1 ), new Milter::SMTPAuth::Child( command => 'smtpauth-filter', arguments => \@filter_arguments, ), ] ); if ( ! $options->foreground() ) { Milter::SMTPAuth::Utils::daemonize( $pid_file ); } $SIG{TERM} = $SIG{INT} = sub { $manager->stop(); if ( -f $pid_file ) { unlink( $pid_file ); } }; $manager->start();