Make daemonize optional

This commit is contained in:
eleksir
2021-08-18 22:45:45 +03:00
parent 1e0181a294
commit c96911f5f8
2 changed files with 9 additions and 3 deletions

View File

@@ -111,8 +111,12 @@ if (defined $logfile) {
Log::Any::Adapter->set ('File', '/dev/null');
}
# double fork attach to /dev/null all stdio and go background
#daemonize ();
# по-умолчанию, демонизируемся, если явно не указано, что этого делать не надо
if (defined ($c->{daemonize}) && $c->{daemonize}) {
daemonize ();
} elsif ( ! defined ($c->{daemonize})) {
daemonize ();
}
# write pidfile
my $apath = abs_path $PROGRAM_NAME;
@@ -122,7 +126,6 @@ unless (defined $apath) {
exit 1;
};
# write pidfile
my $pidfile = sprintf '%s/%s.pid', $piddir, basename $apath;
$log->info ("[INFO] Creating pidfile at $pidfile");

View File

@@ -3,6 +3,9 @@
"server" : "redis",
"port" : "6379",
# should we fork() and become unix daemon?
"daemonize": 1,
# where caches go there
"cachedir" : "data/cache",