Esempio n. 1
0
        die('Could not fork a new process!\\n');
    } elseif ($pid == 0) {
        #we are now in a child process, and the capture_changes
        #below will be daemonized
        pcntl_signal(SIGTERM, "sig_handler");
        pcntl_signal(SIGHUP, "sig_handler");
    } else {
        #return control to the shell
        exit(0);
    }
}
#support pid file
if (!empty($params['pid'])) {
    if (file_exists($params['pid'])) {
        $pid = trim(file_get_contents($params['pid']));
        $ps = `ps -p{$pid}`;
        if (preg_match('/php/i', $ps)) {
            echo "Already running!\n";
            exit(1000);
        } else {
            echo "Stale lockfile detected.\n";
        }
    }
    file_put_contents($params['pid'], getmypid());
}
$error_log = "cleanup_history.err";
$cdc = new FlexCDC($settings);
while (1) {
    $cdc->purge_table_change_history();
    sleep(600);
}