forked from anoff/teamview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (26 loc) · 858 Bytes
/
index.js
File metadata and controls
32 lines (26 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require('dotenv').config()
const { spawn } = require('node:child_process')
const CronJob = require('cron').CronJob
const server = new (require('./lib/server'))()
const logger = require('./lib/logger').child({ module: __filename })
function spawnStatsUpdate () {
const updateStatsProc = spawn('node', ['importStats.js'])
// updateStatsProc.stdout.on('data', (data) => {
// console.error(data.toString('ascii'))
// })
updateStatsProc.stderr.on('data', (data) => {
logger.error('Error occured while running stats update')
// console.error(data.toString('ascii'))
})
updateStatsProc.on('close', (code) => {
logger.info('Terminated stats update child process')
})
}
// start webserver
server.start()
// start cronjob to update stats.json
const updateStats = new CronJob(
'7 * * * *',
spawnStatsUpdate
)
updateStats.start()