fix issue 895 (scheduler creates zombies)

fix bug in windows : tasks did not start
cleanup
This commit is contained in:
jygaulier
2012-09-26 15:27:14 +02:00
committed by Romain Neutron
parent eb73d9b907
commit bfc1ddcb5f
4 changed files with 13 additions and 8 deletions

View File

@@ -143,7 +143,7 @@ class module_console_taskrun extends Command
if (time() - $start > 0) {
if ($this->shedulerPID) {
if ( ! posix_kill($this->shedulerPID, 0)) {
if (function_exists('posix_kill') && !posix_kill($this->shedulerPID, 0)) {
if (method_exists($this->task, 'signal')) {
$this->task->signal('SIGNAL_SCHEDULER_DIED');
} else {

View File

@@ -54,6 +54,11 @@ class task_Scheduler
*/
public function run()
{
if (function_exists('pcntl_signal')) {
// avoid <defunct> php when a task ends
pcntl_signal(SIGCHLD, SIG_IGN);
}
$appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();

View File

@@ -334,7 +334,7 @@ abstract class task_abstract
abstract public function help();
public function __construct($taskid, Logger $logger)
public function __construct($taskid, Logger $logger = NULL)
{
$this->logger = $logger;

View File

@@ -73,9 +73,9 @@ class task_manager
$core = \bootstrap::getCore();
if ( ! $logger) {
$logger = $core['monolog'];
}
// if ( ! $logger) {
// $logger = $core['monolog'];
// }
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
$stmt = $this->appbox->get_connection()->prepare($sql);
@@ -113,9 +113,9 @@ class task_manager
{
$core = \bootstrap::getCore();
if ( ! $logger) {
$logger = $core['monolog'];
}
// if ( ! $logger) {
// $logger = $core['monolog'];
// }
$tasks = $this->getTasks(false, $logger);