config.js 755 B

1234567891011121314151617181920212223242526
  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. module.exports = store;
  17. module.exports.updateSyncTime = function () {
  18. if (env.server && env.exam) {
  19. syncTime[env.server.host + '_' + env.exam.id] = moment().format('YYYY-MM-DD HH:mm:ss')
  20. store['syncTime'] = syncTime
  21. fs.writeFileSync(timeLog, JSON.stringify(syncTime))
  22. }
  23. }