diff options
-rw-r--r-- | src/util.c | 2 | ||||
-rwxr-xr-x | utils/redirector.pl.in | 15 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/util.c b/src/util.c index 589d5b5d9..4ca9a437b 100644 --- a/src/util.c +++ b/src/util.c @@ -813,7 +813,7 @@ open_log (struct config_file *cfg) case RSPAMD_LOG_FILE: cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); if (cfg->log_fd == -1) { - msg_err ("open_log: cannot open desired log file: %s, %s", cfg->log_file, strerror (errno)); + fprintf (stderr, "open_log: cannot open desired log file: %s, %s", cfg->log_file, strerror (errno)); return -1; } return 0; 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); |