Skip to content

Commit

Permalink
added PID file to recurring Invoice cron
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKay85 committed Jan 9, 2019
1 parent 7a47bf6 commit 4208b87
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cron/modules/SalesOrder/RecurringInvoice.service
Expand Up @@ -15,6 +15,15 @@ require_once('include/logging.php');

// Get the list of Invoice for which Recurring is enabled.

$svcname = "RecurringInvoice";
$servicePIDFile = "logs/{$svcname}-service.pid";

if(file_exists($servicePIDFile)) {
die("Service $svcname already running! Check $servicePIDFile");
} else {
$servicePIDFp = fopen($servicePIDFile, 'a');
}

global $adb, $log;
$log =& LoggerManager::getLogger('RecurringInvoice');
$log->debug("invoked RecurringInvoice");
Expand Down Expand Up @@ -100,6 +109,12 @@ for($i=0; $i<$no_of_salesorder;$i++) {
}
}

/** Close and remove the PID file. */
if($servicePIDFp) {
fclose($servicePIDFp);
unlink($servicePIDFile);
}

/* Function to create a new Invoice using the given Sales Order id */
function createInvoice($salesorder_id) {
require_once('include/utils/utils.php');
Expand Down

0 comments on commit 4208b87

Please sign in to comment.