feat: improve log message

This commit is contained in:
fantasticit 2022-04-25 09:19:48 +08:00
parent 5f56dc0448
commit 8f9cecf277
3 changed files with 19 additions and 14 deletions

View File

@ -20,8 +20,7 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe());
app.setGlobalPrefix(config.get('server.prefix') || '/');
await app.listen(config.get('server.port') || 4000);
const url = await app.getUrl();
console.log('服务启动成功:', url);
console.log('[think] 主服务启动成功');
}
bootstrap();

View File

@ -63,14 +63,20 @@ export class CollaborationService {
}
private async initServer() {
try {
const server = Server.configure({
quiet: true,
onAuthenticate: this.onAuthenticate.bind(this),
onLoadDocument: this.onLoadDocument.bind(this),
onChange: this.onChange.bind(this),
onDisconnect: this.onDisconnect.bind(this),
});
this.server = server;
this.server.listen(lodash.get(getConfig(), 'server.collaborationPort', 5003));
await this.server.listen(lodash.get(getConfig(), 'server.collaborationPort', 5003));
console.log('[think] 协作服务启动成功');
} catch (err) {
console.error('[think] 协作服务启动失败:', err.message);
}
}
async onAuthenticate({ connection, token, requestParameters }: onAuthenticatePayload) {

View File

@ -10,7 +10,7 @@ type VerisonDataItem = { version: string; data: string };
export class DocumentVersionService {
private redis: Redis;
private max: number = 0;
private error: string | null = '文档版本服务启动中';
private error: string | null = '[think] 文档版本服务启动中';
constructor() {
this.init();
@ -41,16 +41,16 @@ export class DocumentVersionService {
lazyConnect: true,
});
redis.on('ready', () => {
console.log('文档版本服务启动成功');
console.log('[think] 文档版本服务启动成功');
this.redis = redis;
this.error = null;
});
redis.on('error', (e) => {
console.error(`Redis 启动失败: "${e}"`);
console.error(`[think] Redis 启动失败: "${e}"`);
});
redis.connect().catch((e) => {
this.redis = null;
this.error = 'Redis 启动失败:无法提供文档版本服务';
this.error = '[think] Redis 启动失败:无法提供文档版本服务';
});
} catch (e) {}
}