'use strict'; // app.js module.exports = app => { // 开始前执行 app.beforeStart(async () => { // 此处是你原来的逻辑代码 app.logger.info('启动成功'); // TODO // 考虑所有的下拉都对应一个接口 // 1.5-6上报类型 // 2.br7里面的 驾驶模式等 // 3.11里的远控功能 + app功能(后台处理好一定有名字) // 4.br22里的下拉 // 5.车的人 一定在全量人里得有 在线记录里得人在全量人里得有 || 车行为对应的车必须在全量车里有 // 车娱乐行为对应车行为对应全量车有 app功能的使用人对应全量人有 车辆上报对应车 转换车主对应全量人 tbox对应全车 在线车对应全车 // app 3个用户 里的位置 车机3个用户 里的位置 问题 ==>rbac,onlineuser里通过数据in过滤来源的方式 ==> 多个promise 预处理后聚合处理 // 6.drive_behavior年合计可能需要优化 // }); // 准备好执行 app.ready(async () => { // 举例,获取数据库图片域名,放到缓存,便于使用 }); // 关闭前执行 app.beforeClose(async () => { // this.app.logger 应用级别的日志记录,如记录启动阶段的一些数据信息,记录一些业务上与请求无关的信息 // this.app.coreLogger 开发应用时都不应该通过 CoreLogger 打印日志,而框架和插件则需要通过它来打印应用级别的日志,这样可以更清晰的区分应用和框架打印的日志,通过 CoreLogger 打印的日志会放到和 Logger 不同的文件中 // this.ctx.logger 请求相关的,它打印的日志都会在前面带上一些当前请求相关的信息(如 [$userId/$ip/$traceId/${cost}ms $method $url]) // this.ctx.coreLogger 和 Context Logger 的区别是一般只有插件和框架会通过它来记录日志 // Controller Logger & Service Logger this.logger 本质上就是一个 Context Logger,会额外的加上文件路径 // 同时 Context 上也挂载了 Request 和 Response 两个对象。和 Express 类似, // 这两个对象都提供了大量的便捷方法辅助开发,例如 // // get request.query // get request.hostname // set response.body // set response.status // 参数校验 validate接入egg // this.ctx.curl 相当于ajax }); // 监听 // app.once('server', server => { // // websocket // }); // app.on('error', (err, ctx) => { // // report error // }); // app.on('request', ctx => { // // log receive request // }); // app.on('response', ctx => { // // ctx.starttime is set by framework // const used = Date.now() - ctx.starttime; // // log total cost // }); };