summaryrefslogtreecommitdiff
path: root/src/daemons
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-11-13 12:23:49 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-11-13 12:23:49 +0900
commit2795fe457909c687f668d020ef65d52abc3182fb (patch)
tree0a52e4e4d854333496fcc487560c93c3de5d5eb5 /src/daemons
parentMerge branch 'develop' (diff)
parent12.96.0 (diff)
downloadmisskey-2795fe457909c687f668d020ef65d52abc3182fb.tar.gz
misskey-2795fe457909c687f668d020ef65d52abc3182fb.tar.bz2
misskey-2795fe457909c687f668d020ef65d52abc3182fb.zip
Merge branch 'develop'
Diffstat (limited to 'src/daemons')
-rw-r--r--src/daemons/janitor.ts20
-rw-r--r--src/daemons/queue-stats.ts60
-rw-r--r--src/daemons/server-stats.ts79
3 files changed, 0 insertions, 159 deletions
diff --git a/src/daemons/janitor.ts b/src/daemons/janitor.ts
deleted file mode 100644
index 72568cfe18..0000000000
--- a/src/daemons/janitor.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// TODO: 消したい
-
-const interval = 30 * 60 * 1000;
-import { AttestationChallenges } from '@/models/index';
-import { LessThan } from 'typeorm';
-
-/**
- * Clean up database occasionally
- */
-export default function() {
- async function tick() {
- await AttestationChallenges.delete({
- createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000))
- });
- }
-
- tick();
-
- setInterval(tick, interval);
-}
diff --git a/src/daemons/queue-stats.ts b/src/daemons/queue-stats.ts
deleted file mode 100644
index 77f09b18d6..0000000000
--- a/src/daemons/queue-stats.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import Xev from 'xev';
-import { deliverQueue, inboxQueue } from '../queue/queues';
-
-const ev = new Xev();
-
-const interval = 10000;
-
-/**
- * Report queue stats regularly
- */
-export default function() {
- const log = [] as any[];
-
- ev.on('requestQueueStatsLog', x => {
- ev.emit(`queueStatsLog:${x.id}`, log.slice(0, x.length || 50));
- });
-
- let activeDeliverJobs = 0;
- let activeInboxJobs = 0;
-
- deliverQueue.on('global:active', () => {
- activeDeliverJobs++;
- });
-
- inboxQueue.on('global:active', () => {
- activeInboxJobs++;
- });
-
- async function tick() {
- const deliverJobCounts = await deliverQueue.getJobCounts();
- const inboxJobCounts = await inboxQueue.getJobCounts();
-
- const stats = {
- deliver: {
- activeSincePrevTick: activeDeliverJobs,
- active: deliverJobCounts.active,
- waiting: deliverJobCounts.waiting,
- delayed: deliverJobCounts.delayed
- },
- inbox: {
- activeSincePrevTick: activeInboxJobs,
- active: inboxJobCounts.active,
- waiting: inboxJobCounts.waiting,
- delayed: inboxJobCounts.delayed
- },
- };
-
- ev.emit('queueStats', stats);
-
- log.unshift(stats);
- if (log.length > 200) log.pop();
-
- activeDeliverJobs = 0;
- activeInboxJobs = 0;
- }
-
- tick();
-
- setInterval(tick, interval);
-}
diff --git a/src/daemons/server-stats.ts b/src/daemons/server-stats.ts
deleted file mode 100644
index 8dfa946250..0000000000
--- a/src/daemons/server-stats.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import * as si from 'systeminformation';
-import Xev from 'xev';
-import * as osUtils from 'os-utils';
-
-const ev = new Xev();
-
-const interval = 2000;
-
-const roundCpu = (num: number) => Math.round(num * 1000) / 1000;
-const round = (num: number) => Math.round(num * 10) / 10;
-
-/**
- * Report server stats regularly
- */
-export default function() {
- const log = [] as any[];
-
- ev.on('requestServerStatsLog', x => {
- ev.emit(`serverStatsLog:${x.id}`, log.slice(0, x.length || 50));
- });
-
- async function tick() {
- const cpu = await cpuUsage();
- const memStats = await mem();
- const netStats = await net();
- const fsStats = await fs();
-
- const stats = {
- cpu: roundCpu(cpu),
- mem: {
- used: round(memStats.used - memStats.buffers - memStats.cached),
- active: round(memStats.active),
- },
- net: {
- rx: round(Math.max(0, netStats.rx_sec)),
- tx: round(Math.max(0, netStats.tx_sec)),
- },
- fs: {
- r: round(Math.max(0, fsStats.rIO_sec)),
- w: round(Math.max(0, fsStats.wIO_sec)),
- }
- };
- ev.emit('serverStats', stats);
- log.unshift(stats);
- if (log.length > 200) log.pop();
- }
-
- tick();
-
- setInterval(tick, interval);
-}
-
-// CPU STAT
-function cpuUsage() {
- return new Promise((res, rej) => {
- osUtils.cpuUsage((cpuUsage: number) => {
- res(cpuUsage);
- });
- });
-}
-
-// MEMORY STAT
-async function mem() {
- const data = await si.mem();
- return data;
-}
-
-// NETWORK STAT
-async function net() {
- const iface = await si.networkInterfaceDefault();
- const data = await si.networkStats(iface);
- return data[0];
-}
-
-// FS STAT
-async function fs() {
- const data = await si.disksIO().catch(() => ({ rIO_sec: 0, wIO_sec: 0 }));
- return data || { rIO_sec: 0, wIO_sec: 0 };
-}