修改代码, 添加新的日志输出
This commit is contained in:
parent
f39c3b628f
commit
7a5475b93c
@ -19,7 +19,9 @@ if (!config.disable_super_chat_action) {
|
|||||||
if (!config.disable_super_chat_action) {
|
if (!config.disable_super_chat_action) {
|
||||||
danmakuReceiver.on('SUPER_CHAT_MESSAGE', onSuperChat)
|
danmakuReceiver.on('SUPER_CHAT_MESSAGE', onSuperChat)
|
||||||
}
|
}
|
||||||
|
globalThis.onunload = () => {
|
||||||
|
printLog('主程序', '退出')
|
||||||
|
}
|
||||||
danmakuReceiver.on('closed', () => danmakuReceiver.connect())
|
danmakuReceiver.on('closed', () => danmakuReceiver.connect())
|
||||||
danmakuReceiver.on('LIVE', onLiveStart)
|
danmakuReceiver.on('LIVE', onLiveStart)
|
||||||
danmakuReceiver.on('PREPARING', onLiveEnd)
|
danmakuReceiver.on('PREPARING', onLiveEnd)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { printErr } from "./utils/PrintLog.ts"
|
||||||
|
|
||||||
const pluginSet: Set<Deno.Process> = new Set()
|
const pluginSet: Set<Deno.Process> = new Set()
|
||||||
|
|
||||||
export async function launchAllPlugins() {
|
export async function launchAllPlugins() {
|
||||||
@ -6,23 +8,30 @@ export async function launchAllPlugins() {
|
|||||||
if (plugin.name === '.gitkeep') {
|
if (plugin.name === '.gitkeep') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const pluginProcess = Deno.run({
|
try {
|
||||||
cmd: [`./plugins/${plugin.name}/${plugin.name}`, `./plugins/${plugin.name}/config.json`]
|
const pluginProcess = Deno.run({
|
||||||
})
|
cmd: [`./plugins/${plugin.name}/main`, `./plugins/${plugin.name}/config.json`]
|
||||||
pluginSet.add(pluginProcess)
|
})
|
||||||
|
pluginSet.add(pluginProcess)
|
||||||
|
} catch {
|
||||||
|
printErr('主程序', `启动插件${plugin.name}失败`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Deno.addSignalListener("SIGTERM", () => {
|
function stopAllPlugins() {
|
||||||
for (const pluginProcess of pluginSet) {
|
for (const pluginProcess of pluginSet) {
|
||||||
pluginProcess.kill()
|
pluginProcess.kill()
|
||||||
}
|
}
|
||||||
Deno.exit()
|
Deno.exit()
|
||||||
|
}
|
||||||
|
|
||||||
|
Deno.addSignalListener('SIGTERM', () => {
|
||||||
|
stopAllPlugins()
|
||||||
|
Deno.exit()
|
||||||
})
|
})
|
||||||
|
|
||||||
Deno.addSignalListener("SIGINT", () => {
|
Deno.addSignalListener('SIGINT', () => {
|
||||||
for (const pluginProcess of pluginSet) {
|
stopAllPlugins()
|
||||||
pluginProcess.kill()
|
|
||||||
}
|
|
||||||
Deno.exit()
|
Deno.exit()
|
||||||
})
|
})
|
@ -1,4 +1,7 @@
|
|||||||
import { getTimeString } from './GetTimeString.ts'
|
import { getTimeString } from './GetTimeString.ts'
|
||||||
export function printLog(type: string, msg: unknown) {
|
export function printLog(source: string, msg: unknown) {
|
||||||
console.log(`[${type}][${getTimeString()}] ${msg}`)
|
console.log(`[log][${source}][${getTimeString()}] ${msg}`)
|
||||||
|
}
|
||||||
|
export function printErr(source: string, msg: unknown) {
|
||||||
|
console.error(`[err][${source}][${getTimeString()}] ${msg}`)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user