mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 17:09:07 +08:00
WIP: migrate the logic to handle exception from run-core to ui TODO: test the changes
This commit is contained in:
@@ -15,6 +15,15 @@ import { AUTO_CHAT_ERROR_EXIT_CODE } from '../../../common/enums/auto-start-chat
|
|||||||
import SqlitePluginModule from '@geekgeekrun/sqlite-plugin'
|
import SqlitePluginModule from '@geekgeekrun/sqlite-plugin'
|
||||||
const { default: SqlitePlugin } = SqlitePluginModule
|
const { default: SqlitePlugin } = SqlitePluginModule
|
||||||
|
|
||||||
|
const rerunInterval = (() => {
|
||||||
|
let v = Number(process.env.MAIN_BOSSGEEKGO_RERUN_INTERVAL)
|
||||||
|
if (isNaN(v)) {
|
||||||
|
v = 3000
|
||||||
|
}
|
||||||
|
|
||||||
|
return v
|
||||||
|
})()
|
||||||
|
|
||||||
const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.json')
|
const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.json')
|
||||||
|
|
||||||
const initPlugins = (hooks) => {
|
const initPlugins = (hooks) => {
|
||||||
@@ -98,13 +107,26 @@ export const runAutoChat = async () => {
|
|||||||
try {
|
try {
|
||||||
await mainLoop(hooks)
|
await mainLoop(hooks)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
if (err instanceof Error) {
|
||||||
if (err instanceof Error && err.message.includes('LOGIN_STATUS_INVALID')) {
|
if (err.message.includes('LOGIN_STATUS_INVALID')) {
|
||||||
process.exit(AUTO_CHAT_ERROR_EXIT_CODE.LOGIN_STATUS_INVALID)
|
process.exit(AUTO_CHAT_ERROR_EXIT_CODE.LOGIN_STATUS_INVALID)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
await sleep(3000)
|
if (err.message.includes('ERR_INTERNET_DISCONNECTED')) {
|
||||||
|
process.exit(AUTO_CHAT_ERROR_EXIT_CODE.ERR_INTERNET_DISCONNECTED)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (err.message.includes('ACCESS_IS_DENIED')) {
|
||||||
|
process.exit(AUTO_CHAT_ERROR_EXIT_CODE.ACCESS_IS_DENIED)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closeBrowserWindow?.()
|
||||||
|
console.error(err)
|
||||||
|
console.log(
|
||||||
|
`[Run core main] An internal is caught, and browser will be restarted in ${rerunInterval}ms.`
|
||||||
|
)
|
||||||
|
await sleep(rerunInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closeBrowserWindow()
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user