Add daemon service ISPCONFIG 3
Hi Falko,
crontab -l
* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null
I checked the daemon ISPConfig runs on cron, but cron only runs every one minute, it takes too long to change the configs of the hosts.
You could not put a single daemon in perl done to reduce this time to 20 seconds, here's the script to be placed in /etc/init.d/boot.local
Add script in /etc/init.d/boot.local
/usr/local/ispconfig/server/start_server.pl --start
/usr/local/ispconfig/server/start_server.pl --start (Start)
/usr/local/ispconfig/server/start_server.pl --stop (Stop)
script: /usr/local/ispconfig/server/start_server.pl
#!/usr/bin/perl
use Getopt::Long;
use POSIX qw(setsid);
my $start_daemon = 0;
my $stop_daemon = 0;
GetOptions ('start' => \$start_daemon, 'stop' => \$stop_daemon ) or ( &help );
my $work_dir = '/usr/local/ispconfig/server/';
my $child_STDOUT = '/var/log/ispconfig/ispdaemon.log';
my $pid_file = '/var/run/ispdaemon.pid';
my $exec_command = '/usr/bin/php -q /usr/local/ispconfig/server/server.php';
if($start_daemon){
my $PID = &daemonize();
open PID, ">$pid_file" or die "Can't write to $pid_file: $!";
print PID "$PID\n"; close PID;
while (1) {
print "Start Daemon ispconfig\n";
`$exec_command`;
sleep(20);
}
}
if($stop_daemon){
if(-e $child_STDOUT){
unlink $child_STDOUT;
}
if (-e $pid_file){
chomp(my $pid2 = `cat $pid_file`);
`kill -9 $pid2`;
unlink $pid_file;
}
}
sub daemonize {
chdir $work_dir or die "Can't chdir to $work_dir : $!";
umask 0;
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
#All print statments will now be sent to our log file
open STDOUT, ">>$child_STDOUT" or die "Can't write to $child_STDOUT: $!";
#All error messages will now be sent to our log file
open STDERR, ">>$child_STDOUT" or die "Can't write to $child_STDOUT: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid() or die "Can't start a new session: $!";
my $PROC = $$;
return $PROC;
}
sub help {
print "Usage $0 --start => start daemon ispconfig\n";
print "Usage $0 --stop => stop daemon ispconfig\n";
}