Move process functions to Model\Process

- Add start|endProcess functions to Core\Worker
This commit is contained in:
Hypolite Petovan 2018-01-15 19:08:28 -05:00
parent b699637ab7
commit 78ac7afe9c
5 changed files with 104 additions and 56 deletions

View file

@ -4,11 +4,10 @@
*/
namespace Friendica\Core;
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Process;
use Friendica\Util\Lock;
use dba;
@ -50,7 +49,7 @@ class Worker
}
// We now start the process. This is done after the load check since this could increase the load.
$a->start_process();
self::startProcess();
// Kill stale processes every 5 minutes
$last_cleanup = Config::get('system', 'poller_last_cleaned', 0);
@ -915,7 +914,7 @@ class Worker
if (self::tooMuchWorkers()) {
// Cleaning dead processes
self::killStaleWorkers();
get_app()->remove_inactive_processes();
Process::deleteInactive();
return;
}
@ -1092,4 +1091,31 @@ class Worker
return true;
}
/**
* Log active processes into the "process" table
*
* @brief Log active processes into the "process" table
*/
public static function startProcess()
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$command = basename($trace[0]['file']);
Process::deleteInactive();
Process::insert($command);
}
/**
* Remove the active process from the "process" table
*
* @brief Remove the active process from the "process" table
* @return bool
*/
public static function endProcess()
{
return Process::deleteByPid();
}
}