2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
2024-02-13 09:59:27 -06:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 00:31:52 -05:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2023-05-19 06:52:15 -05:00
|
|
|
<div class="_gaps">
|
2023-01-08 18:42:11 -06:00
|
|
|
<div :class="$style.status">
|
2023-05-19 06:52:15 -05:00
|
|
|
<div :class="$style.statusItem" class="_panel"><div :class="$style.statusLabel">Process</div>{{ number(activeSincePrevTick) }}</div>
|
|
|
|
<div :class="$style.statusItem" class="_panel"><div :class="$style.statusLabel">Active</div>{{ number(active) }}</div>
|
|
|
|
<div :class="$style.statusItem" class="_panel"><div :class="$style.statusLabel">Waiting</div>{{ number(waiting) }}</div>
|
|
|
|
<div :class="$style.statusItem" class="_panel"><div :class="$style.statusLabel">Delayed</div>{{ number(delayed) }}</div>
|
2022-06-25 09:01:40 -05:00
|
|
|
</div>
|
2023-05-19 06:52:15 -05:00
|
|
|
<div :class="$style.charts">
|
|
|
|
<div :class="$style.chart">
|
|
|
|
<div :class="$style.chartTitle">Process</div>
|
2022-06-25 09:01:40 -05:00
|
|
|
<XChart ref="chartProcess" type="process"/>
|
2020-08-09 01:51:02 -05:00
|
|
|
</div>
|
2023-05-19 06:52:15 -05:00
|
|
|
<div :class="$style.chart">
|
|
|
|
<div :class="$style.chartTitle">Active</div>
|
2022-06-25 09:01:40 -05:00
|
|
|
<XChart ref="chartActive" type="active"/>
|
2021-04-22 08:29:33 -05:00
|
|
|
</div>
|
2023-05-19 06:52:15 -05:00
|
|
|
<div :class="$style.chart">
|
|
|
|
<div :class="$style.chartTitle">Delayed</div>
|
2022-06-25 09:01:40 -05:00
|
|
|
<XChart ref="chartDelayed" type="delayed"/>
|
|
|
|
</div>
|
2023-05-19 06:52:15 -05:00
|
|
|
<div :class="$style.chart">
|
|
|
|
<div :class="$style.chartTitle">Waiting</div>
|
2022-06-25 09:01:40 -05:00
|
|
|
<XChart ref="chartWaiting" type="waiting"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-19 06:52:15 -05:00
|
|
|
<MkFolder :defaultOpen="true" :max-height="250">
|
2023-01-08 18:42:11 -06:00
|
|
|
<template #icon><i class="ti ti-alert-triangle"></i></template>
|
|
|
|
<template #label>Errored instances</template>
|
|
|
|
<template #suffix>({{ number(jobs.reduce((a, b) => a + b[1], 0)) }} jobs)</template>
|
2023-06-01 03:19:46 -05:00
|
|
|
|
|
|
|
<div>
|
2023-01-08 18:42:11 -06:00
|
|
|
<div v-if="jobs.length > 0">
|
|
|
|
<div v-for="job in jobs" :key="job[0]">
|
|
|
|
<MkA :to="`/instance-info/${job[0]}`" behavior="window">{{ job[0] }}</MkA>
|
|
|
|
<span style="margin-left: 8px; opacity: 0.7;">({{ number(job[1]) }} jobs)</span>
|
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
2023-01-08 18:42:11 -06:00
|
|
|
<span v-else style="opacity: 0.5;">{{ i18n.ts.noJobs }}</span>
|
2020-03-20 10:21:33 -05:00
|
|
|
</div>
|
2023-01-08 18:42:11 -06:00
|
|
|
</MkFolder>
|
2021-04-22 08:29:33 -05:00
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
2022-05-17 11:31:04 -05:00
|
|
|
<script lang="ts" setup>
|
2023-12-06 23:42:09 -06:00
|
|
|
import { markRaw, onMounted, onUnmounted, ref, shallowRef } from 'vue';
|
2024-08-29 20:58:59 -05:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-06-25 09:01:40 -05:00
|
|
|
import XChart from './queue.chart.chart.vue';
|
2024-08-29 20:58:59 -05:00
|
|
|
import type { ApQueueDomain } from '@/pages/admin/queue.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import number from '@/filters/number.js';
|
2024-01-04 03:32:46 -06:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { useStream } from '@/stream.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2023-01-08 18:42:11 -06:00
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2022-06-25 09:01:40 -05:00
|
|
|
|
2023-05-15 05:08:46 -05:00
|
|
|
const connection = markRaw(useStream().useChannel('queueStats'));
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2022-05-17 11:31:04 -05:00
|
|
|
const activeSincePrevTick = ref(0);
|
|
|
|
const active = ref(0);
|
|
|
|
const delayed = ref(0);
|
2022-06-25 09:01:40 -05:00
|
|
|
const waiting = ref(0);
|
2024-08-29 20:58:59 -05:00
|
|
|
const jobs = ref<Misskey.Endpoints[`admin/queue/${ApQueueDomain}-delayed`]['res']>([]);
|
2023-12-06 23:42:09 -06:00
|
|
|
const chartProcess = shallowRef<InstanceType<typeof XChart>>();
|
|
|
|
const chartActive = shallowRef<InstanceType<typeof XChart>>();
|
|
|
|
const chartDelayed = shallowRef<InstanceType<typeof XChart>>();
|
|
|
|
const chartWaiting = shallowRef<InstanceType<typeof XChart>>();
|
2021-10-22 09:46:47 -05:00
|
|
|
|
2022-05-17 11:31:04 -05:00
|
|
|
const props = defineProps<{
|
2024-08-29 20:58:59 -05:00
|
|
|
domain: ApQueueDomain;
|
2022-05-17 11:31:04 -05:00
|
|
|
}>();
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2024-08-29 20:58:59 -05:00
|
|
|
function onStats(stats: Misskey.entities.QueueStats) {
|
2022-06-25 09:01:40 -05:00
|
|
|
activeSincePrevTick.value = stats[props.domain].activeSincePrevTick;
|
|
|
|
active.value = stats[props.domain].active;
|
|
|
|
delayed.value = stats[props.domain].delayed;
|
|
|
|
waiting.value = stats[props.domain].waiting;
|
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
chartProcess.value.pushData(stats[props.domain].activeSincePrevTick);
|
|
|
|
chartActive.value.pushData(stats[props.domain].active);
|
|
|
|
chartDelayed.value.pushData(stats[props.domain].delayed);
|
|
|
|
chartWaiting.value.pushData(stats[props.domain].waiting);
|
2024-08-29 20:58:59 -05:00
|
|
|
}
|
2022-06-25 09:01:40 -05:00
|
|
|
|
2024-08-29 20:58:59 -05:00
|
|
|
function onStatsLog(statsLog: Misskey.entities.QueueStatsLog) {
|
|
|
|
const dataProcess: Misskey.entities.QueueStats[ApQueueDomain]['activeSincePrevTick'][] = [];
|
|
|
|
const dataActive: Misskey.entities.QueueStats[ApQueueDomain]['active'][] = [];
|
|
|
|
const dataDelayed: Misskey.entities.QueueStats[ApQueueDomain]['delayed'][] = [];
|
|
|
|
const dataWaiting: Misskey.entities.QueueStats[ApQueueDomain]['waiting'][] = [];
|
2022-06-25 09:01:40 -05:00
|
|
|
|
|
|
|
for (const stats of [...statsLog].reverse()) {
|
|
|
|
dataProcess.push(stats[props.domain].activeSincePrevTick);
|
|
|
|
dataActive.push(stats[props.domain].active);
|
|
|
|
dataDelayed.push(stats[props.domain].delayed);
|
|
|
|
dataWaiting.push(stats[props.domain].waiting);
|
|
|
|
}
|
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
chartProcess.value.setData(dataProcess);
|
|
|
|
chartActive.value.setData(dataActive);
|
|
|
|
chartDelayed.value.setData(dataDelayed);
|
|
|
|
chartWaiting.value.setData(dataWaiting);
|
2024-08-29 20:58:59 -05:00
|
|
|
}
|
2022-06-25 09:01:40 -05:00
|
|
|
|
2022-05-17 11:31:04 -05:00
|
|
|
onMounted(() => {
|
2024-08-29 20:58:59 -05:00
|
|
|
misskeyApi(`admin/queue/${props.domain}-delayed`).then(result => {
|
|
|
|
jobs.value = result;
|
|
|
|
});
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2022-06-25 09:01:40 -05:00
|
|
|
connection.on('stats', onStats);
|
|
|
|
connection.on('statsLog', onStatsLog);
|
|
|
|
connection.send('requestLog', {
|
2023-07-13 17:59:54 -05:00
|
|
|
id: Math.random().toString().substring(2, 10),
|
2022-06-25 09:01:40 -05:00
|
|
|
length: 200,
|
2022-05-17 11:31:04 -05:00
|
|
|
});
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
2022-06-25 09:01:40 -05:00
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
connection.off('stats', onStats);
|
|
|
|
connection.off('statsLog', onStatsLog);
|
|
|
|
connection.dispose();
|
|
|
|
});
|
2020-01-29 13:37:25 -06:00
|
|
|
</script>
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2023-05-19 06:52:15 -05:00
|
|
|
<style lang="scss" module>
|
|
|
|
.charts {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
gap: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.chart {
|
|
|
|
min-width: 0;
|
|
|
|
padding: 16px;
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
.chartTitle {
|
|
|
|
margin-bottom: 8px;
|
2023-01-08 18:42:11 -06:00
|
|
|
}
|
2021-04-22 08:29:33 -05:00
|
|
|
|
2023-01-08 18:42:11 -06:00
|
|
|
.status {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
|
|
grid-gap: 10px;
|
2023-05-19 06:52:15 -05:00
|
|
|
}
|
2023-01-08 18:42:11 -06:00
|
|
|
|
2023-05-19 06:52:15 -05:00
|
|
|
.statusItem {
|
|
|
|
padding: 12px 16px;
|
|
|
|
}
|
2023-01-08 18:42:11 -06:00
|
|
|
|
2023-05-19 06:52:15 -05:00
|
|
|
.statusLabel {
|
|
|
|
font-size: 80%;
|
|
|
|
opacity: 0.6;
|
2023-01-08 18:42:11 -06:00
|
|
|
}
|
2021-04-22 08:29:33 -05:00
|
|
|
</style>
|