Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
I
ISPConfig 3
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 504
    • Issues 504
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 28
    • Merge Requests 28
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ISPConfig
  • ISPConfig 3
  • Issues
  • #1991

Closed
Open
Created May 12, 2012 by Nilton OS@jniltinho

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";

}
Edited Apr 26, 2020 by Helmo
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None