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

@@ -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
*/
fwrite($debugHandler, ' cron_tasks: Searching for tasks to do' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Searching for tasks to do");
$cronlog->logAction(CRON_ACTION, LOG_INFO, "cron_tasks: Searching for tasks to do");
$result_tasks_stmt = Database::query("
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
*/
elseif ($row['type'] == '2') {
fwrite($debugHandler, ' cron_tasks: Task2 started - create new home' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task2 started - create new home');
if (is_array($row['data'])) {
// 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
*/
elseif ($row['type'] == '6') {
fwrite($debugHandler, ' cron_tasks: Task6 started - deleting customer data' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task6 started - deleting customer data');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task6 started - deleting customer data');
if (is_array($row['data'])) {
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
*/
elseif ($row['type'] == '7') {
fwrite($debugHandler, ' cron_tasks: Task7 started - deleting customer e-mail data' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task7 started - deleting customer e-mail data');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task7 started - deleting customer e-mail data');
if (is_array($row['data'])) {
@@ -334,8 +330,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
* refs #293
*/
elseif ($row['type'] == '8') {
fwrite($debugHandler, ' cron_tasks: Task8 started - deleting customer ftp homedir' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task8 started - deleting customer ftp homedir');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task8 started - deleting customer ftp homedir');
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) {
fwrite($debugHandler, ' cron_tasks: Task10 started - setting filesystem quota' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task10 started - setting filesystem quota');
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'cron_tasks: Task10 started - setting filesystem quota');
$usedquota = getFilesystemQuota();