country wip
This commit is contained in:
1 parent
7396b40114
commit
97fa1202f0
21 files changed
+757
-3
No files matched your search
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Models\Supervisor;
|
||||
|
||||
class Supervisorctl
|
||||
{
|
||||
public static $starttime = 0;
|
||||
|
||||
public static $code = '';
|
||||
|
||||
public static $events = 0;
|
||||
|
||||
public static function start(&$options)
|
||||
{
|
||||
$debug = $options['d'] ?? 0;
|
||||
|
||||
// sleep 1 sec to avoid error in supervisor
|
||||
sleep(1);
|
||||
|
||||
self::$starttime = microtime(true);
|
||||
|
||||
self::$code = $options['code'];
|
||||
|
||||
$supervisor = Supervisor::where('code', self::$code)->get()->first();
|
||||
|
||||
// if process can be called only from bash
|
||||
if ($supervisor) {
|
||||
$options['sport_id'] = $supervisor->sport_id;
|
||||
$options['customer_id'] = $supervisor->customer_id;
|
||||
$options['limit'] = $supervisor->limit;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('supervisor start '.self::$code, 'g');
|
||||
}
|
||||
|
||||
if ($supervisor->sleep > 0) {
|
||||
if (! $debug) {
|
||||
sleep($supervisor->sleep);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Notice::note('unknown supervisor: '.$options['code'], 'r', 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function end($options)
|
||||
{
|
||||
$processend = microtime(true);
|
||||
$runtime = round(($processend - self::$starttime) / 60, 3);
|
||||
Supervisor::where('code', self::$code)->update(['runtime' => $runtime, 'events' => self::$events]);
|
||||
if ($options['d']) {
|
||||
Notice::note('spervisor time: '.$runtime.' min', 'g');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user