fix: 为图片进程启动必要的配置
This commit is contained in:
		
							parent
							
								
									d84987567a
								
							
						
					
					
						commit
						413f8ef887
					
				|  | @ -1,10 +1,14 @@ | |||
| import '../src/init/modules.js' | ||||
| import '../src/init/logger.js' | ||||
| import '../src/init/config.js' | ||||
| import '../src/init/redis.js' | ||||
| import './tailwindcss.js' | ||||
| import Koa from 'koa' | ||||
| import KoaStatic from 'koa-static' | ||||
| import Router from 'koa-router' | ||||
| import { Component } from 'yunzai/utils' | ||||
| import { readdirSync } from 'fs' | ||||
| import { join } from 'path' | ||||
| import './tailwindcss.js' | ||||
| 
 | ||||
| const Com = new Component() | ||||
| const app = new Koa() | ||||
|  |  | |||
							
								
								
									
										25
									
								
								src/init.ts
								
								
								
								
							
							
						
						
									
										25
									
								
								src/init.ts
								
								
								
								
							|  | @ -1,42 +1,28 @@ | |||
| import './init/modules.js' | ||||
| import './init/logger.js' | ||||
| import './init/config.js' | ||||
| import './init/redis.js' | ||||
| import { promises } from 'node:fs' | ||||
| import yaml from 'yaml' | ||||
| import { configInit } from './config/config' | ||||
| import { BOT_NAME } from './config' | ||||
| import { redisInit } from './config/redis' | ||||
| import { CONFIG_INIT_PATH } from './config/system.js' | ||||
| import { checkRun } from './config/check.js' | ||||
| /** | ||||
|  * | ||||
|  */ | ||||
| logger.mark(`${BOT_NAME} 启动中...`) | ||||
| 
 | ||||
| /** | ||||
|  * 初始化配置 | ||||
|  */ | ||||
| configInit() | ||||
| 
 | ||||
| /** | ||||
|  *  初始化客户端 | ||||
|  */ | ||||
| await redisInit() | ||||
| 
 | ||||
| /** | ||||
|  * 设置标题 | ||||
|  */ | ||||
| process.title = BOT_NAME | ||||
| 
 | ||||
| /** | ||||
|  * 设置时区 | ||||
|  */ | ||||
| process.env.TZ = 'Asia/Shanghai' | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  */ | ||||
| process.on('SIGHUP', () => process.exit()) | ||||
| 
 | ||||
| /** | ||||
|  * 捕获未处理的错误 | ||||
|  */ | ||||
|  | @ -44,7 +30,6 @@ process.on('uncaughtException', error => { | |||
|   if (typeof logger == 'undefined') console.log(error) | ||||
|   else logger.error(error) | ||||
| }) | ||||
| 
 | ||||
| /** | ||||
|  * 捕获未处理的Promise错误 | ||||
|  */ | ||||
|  | @ -52,7 +37,6 @@ process.on('unhandledRejection', error => { | |||
|   if (typeof logger == 'undefined') console.log(error) | ||||
|   else logger.error(error) | ||||
| }) | ||||
| 
 | ||||
| /** | ||||
|  * 退出事件 | ||||
|  */ | ||||
|  | @ -66,18 +50,15 @@ process.on('exit', async () => { | |||
|     logger.mark(logger.magenta(`${BOT_NAME} 已停止运行`)) | ||||
|   } | ||||
| }) | ||||
| 
 | ||||
| /** | ||||
|  * 添加一些多余的标题内容 | ||||
|  */ | ||||
| let title = BOT_NAME | ||||
| 
 | ||||
| //
 | ||||
| const qq = await promises | ||||
|   .readFile(`./${CONFIG_INIT_PATH}qq.yaml`, 'utf-8') | ||||
|   .then(yaml.parse) | ||||
|   .catch(() => null) | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  */ | ||||
|  | @ -113,12 +94,10 @@ if (qq) { | |||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * 设置标题 | ||||
|  */ | ||||
| process.title = title | ||||
| 
 | ||||
| /** | ||||
|  * 检查程序 | ||||
|  */ | ||||
|  |  | |||
|  | @ -0,0 +1,2 @@ | |||
| import { configInit } from '../config/config.js' | ||||
| configInit() | ||||
|  | @ -0,0 +1,2 @@ | |||
| import { redisInit } from '../config/redis' | ||||
| await redisInit() | ||||
		Loading…
	
		Reference in New Issue