mirror of
https://github.com/friendica/friendica
synced 2025-04-26 15:10:11 +00:00
Move process functions to Model\Process
- Add start|endProcess functions to Core\Worker
This commit is contained in:
parent
b699637ab7
commit
78ac7afe9c
5 changed files with 104 additions and 56 deletions
50
src/App.php
50
src/App.php
|
@ -2,20 +2,17 @@
|
|||
|
||||
namespace Friendica;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
use dba;
|
||||
use Friendica\Core\System;
|
||||
|
||||
use Detection\MobileDetect;
|
||||
|
||||
use Exception;
|
||||
|
||||
require_once 'boot.php';
|
||||
require_once 'include/dba.php';
|
||||
require_once 'include/text.php';
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -695,49 +692,6 @@ class App {
|
|||
$this->callstack[$value][$callstack] += (float) $duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Log active processes into the "process" table
|
||||
*/
|
||||
function start_process() {
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
|
||||
|
||||
$command = basename($trace[0]['file']);
|
||||
|
||||
$this->remove_inactive_processes();
|
||||
|
||||
dba::transaction();
|
||||
|
||||
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
|
||||
if (!DBM::is_result($r)) {
|
||||
dba::insert('process', ['pid' => getmypid(), 'command' => $command, 'created' => datetime_convert()]);
|
||||
}
|
||||
dba::commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove inactive processes
|
||||
*/
|
||||
function remove_inactive_processes() {
|
||||
dba::transaction();
|
||||
|
||||
$r = q('SELECT `pid` FROM `process`');
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r AS $process) {
|
||||
if (!posix_kill($process['pid'], 0)) {
|
||||
dba::delete('process', ['pid' => $process['pid']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
dba::commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove the active process from the "process" table
|
||||
*/
|
||||
function end_process() {
|
||||
dba::delete('process', ['pid' => getmypid()]);
|
||||
}
|
||||
|
||||
function get_useragent() {
|
||||
return
|
||||
FRIENDICA_PLATFORM . " '" .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue