Browse Source

dockerfile

release_0.0.2
巴林闲侠 3 years ago
parent
commit
4d6398b7e5
  1. 5
      code/VideoAccess-VCMP/api/Dockerfile
  2. 5
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  3. 4
      code/VideoAccess-VCMP/api/app/lib/index.js
  4. 25
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiState.js
  5. 18
      code/VideoAccess-VCMP/api/app/lib/schedule/index.js

5
code/VideoAccess-VCMP/api/Dockerfile

@ -9,11 +9,8 @@ EXPOSE 8080
RUN npm config set registry=http://10.8.30.22:7000
RUN echo "{\"time\":\"$BUILD_TIMESTAMP\",\"build\": \"$BUILD_NUMBER\",\"revision\": \"$SVN_REVISION_1\",\"URL\":\"$SVN_URL_1\"}" > version.json
RUN npm cache clean -f
RUN rm -rf package-lock.json
RUN npm install --registry http://10.8.30.22:7000
RUN npm run build
RUN rm -rf client/src
RUN rm -rf node_modules
RUN npm install --production --registry http://10.8.30.22:7000
FROM registry.cn-hangzhou.aliyuncs.com/fs-devops/node-16:7.22-06-20

5
code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js

@ -159,6 +159,11 @@ async function detail (ctx) {
const cameraRes = await models.Camera.findOne({
where: {
id: cameraId
},
include: {
model: models.GbCamera,
attributes: ['id', 'online'],
required: false
}
})

4
code/VideoAccess-VCMP/api/app/lib/index.js

@ -7,6 +7,7 @@ const socketConect = require('./service/socket')
const mqttVideoServer = require('./service/mqttVideoServer')
const paasRequest = require('./service/paasRequest');
const authenticator = require('./middlewares/authenticator');
const schedule = require('./schedule')
// const apiLog = require('./middlewares/api-log');
module.exports.entry = function (app, router, opts) {
@ -28,6 +29,9 @@ module.exports.entry = function (app, router, opts) {
// 工具类函数
utils(app, opts)
// 定时任务
// schedule(app, opts)
// 鉴权中间件
router.use(authenticator(app, opts));

25
code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiState.js

@ -0,0 +1,25 @@
const schedule = require('node-schedule');
const moment = require('moment')
module.exports = function (app, opts) {
const freshYingshiState = schedule.scheduleJob(
'* * 4 * * *',
// '* */1 * * * *',
async () => {
try {
const { models } = app.fs.dc
await models.UserToken.destroy({
where: {
expired: { $lt: now }
}
})
} catch (error) {
app.fs.logger.error(`sechedule: freshYingshiState, error: ${error}`);
}
});
return {
freshYingshiState
}
}

18
code/VideoAccess-VCMP/api/app/lib/schedule/index.js

@ -0,0 +1,18 @@
'use strict';
const fs = require('fs');
// 将定时任务汇集未来可根据需要选取操作
module.exports = async function (app, opts) {
fs.readdirSync(__dirname).forEach((filename) => {
if (!['index.js'].some(f => filename == f)) {
const schedule = require(`./${filename}`)(app, opts)
for (let k of Object.keys(schedule)) {
console.info(`定时任务 ${k} 启动`);
}
app.fs.utils = {
...app.fs.schedule,
...schedule,
}
}
});
};
Loading…
Cancel
Save