aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-06 13:09:32 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-06 13:09:32 +0300
commit514d83c13d1f22263c9662154e7459cdbff51c97 (patch)
tree2f2b4823f4fca3c20439ebe28efc14f570378a44 /utils
parent8c09632127fb53347239f5f35c0049d8d316a607 (diff)
downloadrspamd-514d83c13d1f22263c9662154e7459cdbff51c97.tar.gz
rspamd-514d83c13d1f22263c9662154e7459cdbff51c97.zip
* Fix initialization procedure of redirector
* Do not write to log file if we cannot open it
Diffstat (limited to 'utils')
-rwxr-xr-xutils/redirector.pl.in15
1 files changed, 7 insertions, 8 deletions
diff --git a/utils/redirector.pl.in b/utils/redirector.pl.in
index da3451580..c406b48a3 100755
--- a/utils/redirector.pl.in
+++ b/utils/redirector.pl.in
@@ -40,7 +40,7 @@ my %cfg = (
max_rec => 5,
pidfile => '/var/run/rspamd/redirector.pid',
logfile => '/var/log/rspamd-redirector.log',
- do_log => 1,
+ do_log => 0,
debug => 0,
digest_bits => 256,
cache_expire => 3600,
@@ -50,6 +50,11 @@ my %cfg = (
our $do_reopen_log = 0;
+die "Process is already started, check $cfg{pidfile}" if Proc::PidUtil::is_running($cfg{pidfile});
+
+# Do daemonization
+Proc::Daemon::Init if !$cfg{debug};
+
# Drop privilleges
if ($> == 0) {
my $uid = getpwnam($cfg{user}) or die "user $cfg{user} unknown";
@@ -58,15 +63,10 @@ if ($> == 0) {
$) = $gid;
}
-die "Process is already started, check $cfg{pidfile}" if Proc::PidUtil::is_running($cfg{pidfile});
-
die "Cannot write to pidfile $cfg{pidfile}" if ! open(PID, "> $cfg{pidfile}");
close(PID);
-$cfg{do_log} = 0 if ! open(LOG, ">> $cfg{logfile}");
-
-# Do daemonization
-Proc::Daemon::Init if !$cfg{debug};
+$cfg{do_log} = 1 if open(LOG, ">> $cfg{logfile}");
Proc::PidUtil::make_pidfile($cfg{pidfile}, $$) or die "Cannot write pidfile $cfg{pidfile}";
@@ -443,7 +443,6 @@ POE::Kernel->run();
exit 0;
END {
- unlink($cfg{pidfile});
if ($cfg{do_log}) {
write_log ("", "Stopping URL resolver");
close (LOG);