cron scripts: replace fwrite'ing to lockfile by logging

This commit is contained in:
Daniel Reichelt
2016-02-16 15:04:20 +01:00
parent f65af0067d
commit f86a115c6a
10 changed files with 56 additions and 95 deletions

View File

@@ -18,7 +18,7 @@
* *
*/ */
fwrite($debugHandler, "calculating mailspace usage\n"); $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'calculating mailspace usage');
$maildirs_stmt = Database::query(" $maildirs_stmt = Database::query("
SELECT `id`, CONCAT(`homedir`, `maildir`) AS `maildirpath` FROM `".TABLE_MAIL_USERS."` ORDER BY `id` SELECT `id`, CONCAT(`homedir`, `maildir`) AS `maildirpath` FROM `".TABLE_MAIL_USERS."` ORDER BY `id`
@@ -50,6 +50,6 @@ while ($maildir = $maildirs_stmt->fetch(PDO::FETCH_ASSOC)) {
unset($back); unset($back);
Database::pexecute($upd_stmt, array('size' => $emailusage, 'id' => $maildir['id'])); Database::pexecute($upd_stmt, array('size' => $emailusage, 'id' => $maildir['id']));
} else { } else {
fwrite($debugHandler, 'maildir ' . $_maildir . ' does not exist' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $_maildir . ' does not exist');
} }
} }

View File

@@ -67,7 +67,6 @@ class bind {
public function writeConfigs() { public function writeConfigs() {
fwrite($this->debugHandler, ' cron_tasks: Task4 started - Rebuilding froxlor_bind.conf' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf');
if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) { if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
@@ -130,22 +129,20 @@ class bind {
} }
} }
fwrite($this->debugHandler, $this->logger->logAction(CRON_ACTION, LOG_DEBUG,
str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') . str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') .
'ismainbutsubto ' . str_pad('parent domain', 40, ' ') . 'ismainbutsubto ' . str_pad('parent domain', 40, ' ') .
"list of child domain ids\n"); "list of child domain ids");
foreach ($domains as $domain) { foreach ($domains as $domain) {
fwrite($this->debugHandler, $logLine =
str_pad($domain['id'], 9, ' ') . str_pad($domain['id'], 9, ' ') .
str_pad($domain['domain'], 40, ' ') . str_pad($domain['domain'], 40, ' ') .
str_pad($domain['ismainbutsubto'], 15, ' ') . str_pad($domain['ismainbutsubto'], 15, ' ') .
str_pad(((isset($domains[ $domain['ismainbutsubto'] ])) ? str_pad(((isset($domains[ $domain['ismainbutsubto'] ])) ?
$domains[ $domain['ismainbutsubto'] ]['domain'] : $domains[ $domain['ismainbutsubto'] ]['domain'] :
'-'), 40, ' ')); '-'), 40, ' ') .
foreach ($domain['children'] as $child) { join(', ', $domain['children']);
fwrite($this->debugHandler, '$child, '); $this->logger->logAction(CRON_ACTION, LOG_DEBUG, $logLine);
}
fwrite($this->debugHandler, "\n");
} }
foreach ($domains as $domain) { foreach ($domains as $domain) {
@@ -159,10 +156,8 @@ class bind {
$bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w'); $bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w');
fwrite($bindconf_file_handler, $this->_bindconf_file); fwrite($bindconf_file_handler, $this->_bindconf_file);
fclose($bindconf_file_handler); fclose($bindconf_file_handler);
fwrite($this->debugHandler, ' cron_tasks: Task4 - froxlor_bind.conf written' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command'))); safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command')));
fwrite($this->debugHandler, ' cron_tasks: Task4 - Bind9 reloaded' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded');
$domains_dir = makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'); $domains_dir = makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/');
@@ -178,12 +173,12 @@ class bind {
&& !in_array($domain_filename, $this->_known_filenames) && !in_array($domain_filename, $this->_known_filenames)
&& is_file($full_filename) && is_file($full_filename)
&& file_exists($full_filename)) { && file_exists($full_filename)) {
fwrite($this->debugHandler, ' cron_tasks: Task4 - unlinking ' . $domain_filename . "\n");
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'Deleting ' . $domain_filename); $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'Deleting ' . $domain_filename);
unlink(makeCorrectFile($domains_dir . '/' . $domain_filename)); unlink(makeCorrectFile($domains_dir . '/' . $domain_filename));
} }
} }
} }
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 finished');
} }
private function walkDomainList($domain, $domains) { private function walkDomainList($domain, $domains) {
@@ -202,7 +197,7 @@ class bind {
$zonefile_handler = fopen($zonefile_name, 'w'); $zonefile_handler = fopen($zonefile_name, 'w');
fwrite($zonefile_handler, $zonefile.$subzones); fwrite($zonefile_handler, $zonefile.$subzones);
fclose($zonefile_handler); fclose($zonefile_handler);
fwrite($this->debugHandler, ' cron_tasks: Task4 - `' . $zonefile_name . '` zone written' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, '`' . $zonefile_name . '` zone written');
} else { } else {
return $this->generateZone($domain); return $this->generateZone($domain);
} }
@@ -600,7 +595,6 @@ class bind {
fclose($dkimkeys_file_handler); fclose($dkimkeys_file_handler);
safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command'))); safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command')));
fwrite($this->debugHandler, ' cron_tasks: Task4 - Dkim-milter reloaded' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
} }
} }

View File

@@ -49,12 +49,10 @@ class apache extends HttpConfigBase {
public function reload() { public function reload() {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' apache::reload: reloading php-fpm' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading php-fpm');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
} }
fwrite($this->debugHandler, ' apache::reload: reloading apache' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading apache');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache');
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command'))); safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
} }
@@ -76,8 +74,7 @@ class apache extends HttpConfigBase {
) { ) {
// if we use fcgid or php-fpm we don't need this file // if we use fcgid or php-fpm we don't need this file
if (file_exists($vhosts_filename)) { if (file_exists($vhosts_filename)) {
fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename));
unlink(makeCorrectFile($vhosts_filename)); unlink(makeCorrectFile($vhosts_filename));
} }
} else { } else {
@@ -147,8 +144,7 @@ class apache extends HttpConfigBase {
$ipport = $row_ipsandports['ip'] . ':' . $row_ipsandports['port']; $ipport = $row_ipsandports['ip'] . ':' . $row_ipsandports['port'];
} }
fwrite($this->debugHandler, ' apache::createIpPort: creating ip/port settings for ' . $ipport . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::createIpPort: creating ip/port settings for ' . $ipport);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ipport);
$vhosts_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf'); $vhosts_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->virtualhosts_data[$vhosts_filename])) { if (!isset($this->virtualhosts_data[$vhosts_filename])) {
@@ -895,8 +891,7 @@ class apache extends HttpConfigBase {
$domains = WebserverBase::getVhostsToCreate(); $domains = WebserverBase::getVhostsToCreate();
foreach ($domains as $domain) { foreach ($domains as $domain) {
fwrite($this->debugHandler, ' apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname'] . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
$vhosts_filename = $this->getVhostFilename($domain); $vhosts_filename = $this->getVhostFilename($domain);
// Apply header // Apply header
@@ -995,7 +990,7 @@ class apache extends HttpConfigBase {
} else { } else {
$this->diroptions_data[$diroptions_filename] .= "\n"; $this->diroptions_data[$diroptions_filename] .= "\n";
} }
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options +Indexes' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options +Indexes');
} }
if (isset($row_diroptions['options_indexes']) if (isset($row_diroptions['options_indexes'])
@@ -1012,7 +1007,7 @@ class apache extends HttpConfigBase {
} else { } else {
$this->diroptions_data[$diroptions_filename] .= "\n"; $this->diroptions_data[$diroptions_filename] .= "\n";
} }
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options -Indexes');
} }
$statusCodes = array('404', '403', '500'); $statusCodes = array('404', '403', '500');
@@ -1048,7 +1043,7 @@ class apache extends HttpConfigBase {
$this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n";
$this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n";
} }
fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Enabling perl execution');
// check for suexec-workaround, #319 // check for suexec-workaround, #319
if ((int)Settings::Get('perl.suexecworkaround') == 1) { if ((int)Settings::Get('perl.suexecworkaround') == 1) {
@@ -1116,8 +1111,7 @@ class apache extends HttpConfigBase {
*/ */
public function writeConfigs() { public function writeConfigs() {
// Write diroptions // Write diroptions
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_diroptions') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_diroptions'));
if (count($this->diroptions_data) > 0) { if (count($this->diroptions_data) > 0) {
$optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions')); $optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions'));
@@ -1138,8 +1132,7 @@ class apache extends HttpConfigBase {
fclose($diroptions_file_handler); fclose($diroptions_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_diroptions'))) { if (!file_exists(Settings::Get('system.apacheconf_diroptions'))) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
} }
@@ -1157,8 +1150,7 @@ class apache extends HttpConfigBase {
} }
// Write htpasswds // Write htpasswds
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_htpasswddir') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
if (count($this->htpasswds_data) > 0) { if (count($this->htpasswds_data) > 0) {
if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) { if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
@@ -1177,15 +1169,12 @@ class apache extends HttpConfigBase {
fclose($htpasswd_file_handler); fclose($htpasswd_file_handler);
} }
} else { } else {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!'); $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
} }
} }
// Write virtualhosts // Write virtualhosts
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
if (count($this->virtualhosts_data) > 0) { if (count($this->virtualhosts_data) > 0) {
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
@@ -1218,8 +1207,7 @@ class apache extends HttpConfigBase {
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) { if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
} }

View File

@@ -49,12 +49,10 @@ class lighttpd extends HttpConfigBase {
public function reload() { public function reload() {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading php-fpm');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
} }
fwrite($this->debugHandler, ' lighttpd::reload: reloading lighttpd' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading lighttpd');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading lighttpd');
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command'))); safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
} }
@@ -73,8 +71,7 @@ class lighttpd extends HttpConfigBase {
$ipv6 = ''; $ipv6 = '';
} }
fwrite($this->debugHandler, ' lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf'); $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->lighttpd_data[$vhost_filename])) { if (!isset($this->lighttpd_data[$vhost_filename])) {
@@ -861,8 +858,7 @@ class lighttpd extends HttpConfigBase {
public function writeConfigs() { public function writeConfigs() {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
if (!$vhostDir->isConfigDir()) { if (!$vhostDir->isConfigDir()) {
@@ -889,8 +885,7 @@ class lighttpd extends HttpConfigBase {
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) { if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
} }

View File

@@ -49,8 +49,7 @@ class nginx extends HttpConfigBase {
public function reload() { public function reload() {
fwrite($this->debugHandler, ' nginx::reload: reloading nginx' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading nginx');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading nginx');
safe_exec(Settings::Get('system.apachereload_command')); safe_exec(Settings::Get('system.apachereload_command'));
/** /**
@@ -59,12 +58,10 @@ class nginx extends HttpConfigBase {
if (Settings::Get('system.phpreload_command') != '' if (Settings::Get('system.phpreload_command') != ''
&& (int)Settings::Get('phpfpm.enabled') == 0 && (int)Settings::Get('phpfpm.enabled') == 0
) { ) {
fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: restarting php processes');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes');
safe_exec(Settings::Get('system.phpreload_command')); safe_exec(Settings::Get('system.phpreload_command'));
} elseif ((int)Settings::Get('phpfpm.enabled') == 1) { } elseif ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading php-fpm');
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload'))); safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
} }
} }
@@ -128,8 +125,7 @@ class nginx extends HttpConfigBase {
} }
$port = $row_ipsandports['port']; $port = $row_ipsandports['port'];
fwrite($this->debugHandler, ' nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf'); $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->nginx_data[$vhost_filename])) { if (!isset($this->nginx_data[$vhost_filename])) {
@@ -1002,8 +998,7 @@ class nginx extends HttpConfigBase {
public function writeConfigs() { public function writeConfigs() {
fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "nginx::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost')); $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
if (!$vhostDir->isConfigDir()) { if (!$vhostDir->isConfigDir()) {
@@ -1029,8 +1024,7 @@ class nginx extends HttpConfigBase {
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} else { } else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) { if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost')))); safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
} }
@@ -1058,8 +1052,6 @@ class nginx extends HttpConfigBase {
mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751); mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751);
umask($umask); umask($umask);
} elseif (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) { } elseif (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!'); $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
} }

View File

@@ -29,8 +29,7 @@ require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.35.nginx_
/** /**
* LOOK INTO TASKS TABLE TO SEE IF THERE ARE ANY UNDONE JOBS * LOOK INTO TASKS TABLE TO SEE IF THERE ARE ANY UNDONE JOBS
*/ */
fwrite($debugHandler, ' cron_tasks: Searching for tasks to do' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "cron_tasks: Searching for tasks to do");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Searching for tasks to do");
$result_tasks_stmt = Database::query(" $result_tasks_stmt = Database::query("
SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` <> '99' ORDER BY `id` ASC SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` <> '99' ORDER BY `id` ASC
"); ");
@@ -112,8 +111,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* TYPE=2 MEANS TO CREATE A NEW HOME AND CHOWN * TYPE=2 MEANS TO CREATE A NEW HOME AND CHOWN
*/ */
elseif ($row['type'] == '2') { elseif ($row['type'] == '2') {
fwrite($debugHandler, ' cron_tasks: Task2 started - create new home' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task2 started - create new home');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home');
if (is_array($row['data'])) { if (is_array($row['data'])) {
// define paths // define paths
@@ -201,8 +199,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* TYPE=6 MEANS THAT A CUSTOMER HAS BEEN DELETED AND THAT WE HAVE TO REMOVE ITS FILES * TYPE=6 MEANS THAT A CUSTOMER HAS BEEN DELETED AND THAT WE HAVE TO REMOVE ITS FILES
*/ */
elseif ($row['type'] == '6') { elseif ($row['type'] == '6') {
fwrite($debugHandler, ' cron_tasks: Task6 started - deleting customer data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task6 started - deleting customer data');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task6 started - deleting customer data');
if (is_array($row['data'])) { if (is_array($row['data'])) {
if (isset($row['data']['loginname'])) { if (isset($row['data']['loginname'])) {
@@ -268,8 +265,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* TYPE=7 Customer deleted an email account and wants the data to be deleted on the filesystem * TYPE=7 Customer deleted an email account and wants the data to be deleted on the filesystem
*/ */
elseif ($row['type'] == '7') { elseif ($row['type'] == '7') {
fwrite($debugHandler, ' cron_tasks: Task7 started - deleting customer e-mail data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task7 started - deleting customer e-mail data');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task7 started - deleting customer e-mail data');
if (is_array($row['data'])) { if (is_array($row['data'])) {
@@ -334,8 +330,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* refs #293 * refs #293
*/ */
elseif ($row['type'] == '8') { elseif ($row['type'] == '8') {
fwrite($debugHandler, ' cron_tasks: Task8 started - deleting customer ftp homedir' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task8 started - deleting customer ftp homedir');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task8 started - deleting customer ftp homedir');
if (is_array($row['data'])) { if (is_array($row['data'])) {
@@ -363,8 +358,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
*/ */
elseif ($row['type'] == '10' && (int)Settings::Get('system.diskquota_enabled') != 0) { elseif ($row['type'] == '10' && (int)Settings::Get('system.diskquota_enabled') != 0) {
fwrite($debugHandler, ' cron_tasks: Task10 started - setting filesystem quota' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task10 started - setting filesystem quota');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task10 started - setting filesystem quota');
$usedquota = getFilesystemQuota(); $usedquota = getFilesystemQuota();

View File

@@ -20,7 +20,7 @@
/** /**
* ARCHIVING CLOSED TICKETS * ARCHIVING CLOSED TICKETS
*/ */
fwrite($debugHandler, 'Ticket-archiving run started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Ticket-archiving run started...');
$result_tickets_stmt = Database::query(" $result_tickets_stmt = Database::query("
SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "` SELECT `id`, `lastchange`, `subject` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `status` = '3' AND `answerto` = '0';" WHERE `status` = '3' AND `answerto` = '0';"
@@ -35,7 +35,7 @@ while ($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($days >= Settings::Get('ticket.archiving_days')) { if ($days >= Settings::Get('ticket.archiving_days')) {
fwrite($debugHandler, 'archiving ticket "' . $row_ticket['subject'] . '" (ID #' . $row_ticket['id'] . ')' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'archiving ticket "' . $row_ticket['subject'] . '" (ID #' . $row_ticket['id'] . ')');
$mainticket = ticket::getInstanceOf(null, (int)$row_ticket['id']); $mainticket = ticket::getInstanceOf(null, (int)$row_ticket['id']);
$mainticket->Set('lastchange', $now, true, true); $mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true); $mainticket->Set('lastreplier', '1', true, true);
@@ -46,7 +46,7 @@ while ($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
} }
} }
fwrite($debugHandler, 'Archived ' . $archiving_count . ' tickets' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Archived ' . $archiving_count . ' tickets');
Database::query(" Database::query("
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP() UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP()
WHERE `settinggroup` = 'system' AND `varname` = 'last_archive_run'" WHERE `settinggroup` = 'system' AND `varname` = 'last_archive_run'"

View File

@@ -30,7 +30,7 @@ if (function_exists('pcntl_fork')) {
$TrafficPidStatus = $TrafficPidStatus ? false : true; $TrafficPidStatus = $TrafficPidStatus ? false : true;
} }
if ($TrafficPidStatus) { if ($TrafficPidStatus) {
fwrite($debugHandler,"Traffic Run already in progress\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic Run already in progress');
return 1; return 1;
} }
} }
@@ -49,7 +49,6 @@ if (function_exists('pcntl_fork')) {
elseif ($TrafficPid == 0) { elseif ($TrafficPid == 0) {
posix_setsid(); posix_setsid();
fclose($debugHandler); fclose($debugHandler);
$debugHandler = fopen("/tmp/froxlor_traffic.log", "w");
// re-create db // re-create db
Database::needRoot(false); Database::needRoot(false);
} }
@@ -64,7 +63,7 @@ if (function_exists('pcntl_fork')) {
} else { } else {
$msg = "PHP compiled without pcntl."; $msg = "PHP compiled without pcntl.";
} }
fwrite($debugHandler, $msg." Not forking traffic-cron, this may take a long time!"); $cronlog->logAction(CRON_ACTION, LOG_INFO, $msg." Not forking traffic-cron, this may take a long time!");
} }
require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.php'); require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.php');
@@ -72,7 +71,7 @@ require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.ph
/** /**
* TRAFFIC AND DISKUSAGE MESSURE * TRAFFIC AND DISKUSAGE MESSURE
*/ */
fwrite($debugHandler, 'Traffic run started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic run started...');
$admin_traffic = array(); $admin_traffic = array();
$domainlist = array(); $domainlist = array();
$speciallogfile_domainlist = array(); $speciallogfile_domainlist = array();
@@ -164,7 +163,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* HTTP-Traffic * HTTP-Traffic
*/ */
fwrite($debugHandler, 'http traffic for ' . $row['loginname'] . ' started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'http traffic for ' . $row['loginname'] . ' started...');
$httptraffic = 0; $httptraffic = 0;
if (isset($domainlist[$row['customerid']]) if (isset($domainlist[$row['customerid']])
@@ -225,7 +224,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* FTP-Traffic * FTP-Traffic
*/ */
fwrite($debugHandler, 'ftp traffic for ' . $row['loginname'] . ' started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'ftp traffic for ' . $row['loginname'] . ' started...');
$ftptraffic_stmt = Database::prepare(" $ftptraffic_stmt = Database::prepare("
SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum` SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum`
FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid
@@ -249,7 +248,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
*/ */
$mailtraffic = 0; $mailtraffic = 0;
if (Settings::Get("system.mailtraffic_enabled")) { if (Settings::Get("system.mailtraffic_enabled")) {
fwrite($debugHandler, 'mail traffic usage for ' . $row['loginname'] . " started...\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'mail traffic usage for ' . $row['loginname'] . " started...");
$currentDate = date("Y-m-d"); $currentDate = date("Y-m-d");
@@ -294,7 +293,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* Total Traffic * Total Traffic
*/ */
fwrite($debugHandler, 'total traffic for ' . $row['loginname'] . ' started' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'total traffic for ' . $row['loginname'] . ' started');
$current_traffic = array(); $current_traffic = array();
$current_traffic['http'] = floatval($httptraffic); $current_traffic['http'] = floatval($httptraffic);
$current_traffic['ftp_up'] = floatval(($ftptraffic['up_bytes_sum'] / 1024)); $current_traffic['ftp_up'] = floatval(($ftptraffic['up_bytes_sum'] / 1024));
@@ -355,7 +354,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/** /**
* WebSpace-Usage * WebSpace-Usage
*/ */
fwrite($debugHandler, 'calculating webspace usage for ' . $row['loginname'] . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating webspace usage for ' . $row['loginname']);
$webspaceusage = 0; $webspaceusage = 0;
// Using repquota, it's faster using this tool than using du traversing the complete directory // Using repquota, it's faster using this tool than using du traversing the complete directory
@@ -381,14 +380,14 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
unset($back); unset($back);
} else { } else {
fwrite($debugHandler, 'documentroot ' . $row['documentroot'] . ' does not exist' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'documentroot ' . $row['documentroot'] . ' does not exist');
} }
} }
/** /**
* MailSpace-Usage * MailSpace-Usage
*/ */
fwrite($debugHandler, 'calculating mailspace usage for ' . $row['loginname'] . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating mailspace usage for ' . $row['loginname']);
$emailusage = 0; $emailusage = 0;
$maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']); $maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']);
@@ -402,13 +401,13 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
unset($back); unset($back);
} else { } else {
fwrite($debugHandler, 'maildir ' . $maildir . ' does not exist' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $maildir . ' does not exist');
} }
/** /**
* MySQLSpace-Usage * MySQLSpace-Usage
*/ */
fwrite($debugHandler, 'calculating mysqlspace usage for ' . $row['loginname'] . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating mysqlspace usage for ' . $row['loginname']);
$mysqlusage = 0; $mysqlusage = 0;
if (isset($mysqlusage_all[$row['customerid']])) { if (isset($mysqlusage_all[$row['customerid']])) {

View File

@@ -17,7 +17,7 @@
* *
*/ */
fwrite($debugHandler, 'Web- and Traffic-usage reporting started...' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Web- and Traffic-usage reporting started...');
$yesterday = time() - (60 * 60 * 24); $yesterday = time() - (60 * 60 * 24);
/** /**

View File

@@ -20,6 +20,5 @@
/** /**
* RESET USED TICKETS COUNTER * RESET USED TICKETS COUNTER
*/ */
fwrite($debugHandler, 'Resetting customers used ticket counter' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Resetting customers used ticket counter"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Resetting customers used ticket counter");
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `tickets_used` = '0'");