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