This commit is contained in:
parent
d0a7432af1
commit
27deb4be75
|
@ -15,7 +15,7 @@
|
|||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getShortcutContent" />
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getQaCityList" />
|
||||
|
||||
<el-dialog title="添加城市" :visible.sync="dialogCreate">
|
||||
<el-form label-width="120px" :model="anchors">
|
||||
|
|
|
@ -266,7 +266,7 @@ class Douyin
|
|||
return true;
|
||||
}
|
||||
|
||||
public function _killMiddleProcesses($pattern, $maxProcesses)
|
||||
/*public function _killMiddleProcesses($pattern, $maxProcesses)
|
||||
{
|
||||
// 检查操作系统是否为 Linux
|
||||
if (PHP_OS !== 'Linux') {
|
||||
|
@ -297,6 +297,7 @@ class Douyin
|
|||
$minutes = intval($runtimeParts[1]);
|
||||
$totalMinutes = $hours * 60 + $minutes;
|
||||
|
||||
|
||||
if ($pid !== $currentPid) {
|
||||
exec("kill -9 $pid");
|
||||
$processesKilled++;
|
||||
|
@ -315,9 +316,78 @@ class Douyin
|
|||
} else {
|
||||
echo "Process count is not over the limit.\n";
|
||||
}
|
||||
return true;
|
||||
}*/
|
||||
|
||||
public function _killMiddleProcesses($pattern, $maxProcesses)
|
||||
{
|
||||
// 检查操作系统是否为 Linux
|
||||
if (PHP_OS !== 'Linux') {
|
||||
echo "当前系统不是 Linux,跳过执行。\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取当前进程的 PID
|
||||
$currentPid = getmypid();
|
||||
|
||||
// 获取进程列表
|
||||
$command = "ps aux | grep '$pattern' | grep -v grep | grep -v '$currentPid' | awk '{print $2,$10}'";
|
||||
$output = [];
|
||||
exec($command, $output);
|
||||
|
||||
$processList = [];
|
||||
foreach ($output as $line) {
|
||||
list($pid, $runtime) = explode(' ', $line);
|
||||
$runtimeParts = explode(':', $runtime);
|
||||
$hours = intval($runtimeParts[0]);
|
||||
$minutes = intval($runtimeParts[1]);
|
||||
$totalMinutes = $hours * 60 + $minutes;
|
||||
$processList[] = ['pid' => $pid, 'runtime' => $totalMinutes];
|
||||
}
|
||||
|
||||
// 按运行时间排序
|
||||
usort($processList, function ($a, $b) {
|
||||
return $a['runtime'] <=> $b['runtime'];
|
||||
});
|
||||
|
||||
// 过滤掉当前 PID 和运行时间最短的 PID
|
||||
if (!empty($processList)) {
|
||||
array_shift($processList); // 移除运行时间最短的
|
||||
}
|
||||
$processList = array_filter($processList, function ($process) use ($currentPid) {
|
||||
return $process['pid'] != $currentPid;
|
||||
});
|
||||
|
||||
$processCount = count($processList);
|
||||
|
||||
// 如果进程数量超过最大值,则终止中间部分的进程
|
||||
if ($processCount > $maxProcesses) {
|
||||
$processesToKill = $processCount - $maxProcesses;
|
||||
$processesKilled = 0;
|
||||
|
||||
// 杀死运行时间最短的进程
|
||||
foreach ($processList as $process) {
|
||||
if ($processesKilled >= $processesToKill) {
|
||||
break;
|
||||
}
|
||||
|
||||
exec("kill -9 {$process['pid']}");
|
||||
$processesKilled++;
|
||||
|
||||
echo "Killed process with PID: {$process['pid']}\n";
|
||||
}
|
||||
|
||||
if ($processesKilled === 0) {
|
||||
echo "No processes to kill.\n";
|
||||
}
|
||||
} else {
|
||||
echo "Process count is not over the limit.\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function _orderDetail($orderId = null, $status = null)
|
||||
{
|
||||
$orderDetail = $this->_curl("/life/trip/v2/travel_agency/book/detail", [
|
||||
|
|
Loading…
Reference in New Issue