config.js 825 B

123456789101112131415161718192021222324252627282930
  1. const fs = require('fs')
  2. const path = require('path')
  3. const moment = require('moment')
  4. const store = require('../../config.json')
  5. const env = require('./env.js')
  6. let timeLog = path.join(__dirname, '../../logs/time.log')
  7. let syncTime = {}
  8. if (fs.existsSync(path.join(__dirname, '../../logs/time.log'))) {
  9. try {
  10. syncTime = JSON.parse(fs.readFileSync(timeLog))
  11. } catch (err) {
  12. syncTime = {}
  13. }
  14. }
  15. store['syncTime'] = syncTime
  16. store['upyun'] = {
  17. operator: 'qmth',
  18. password: 'qmth123456'
  19. }
  20. module.exports = store;
  21. module.exports.updateSyncTime = function () {
  22. if (env.server && env.exam) {
  23. syncTime[env.server.host + '_' + env.exam.id] = moment().format('YYYY-MM-DD HH:mm:ss')
  24. store['syncTime'] = syncTime
  25. fs.writeFileSync(timeLog, JSON.stringify(syncTime))
  26. }
  27. }