-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
executable file
·37 lines (31 loc) · 927 Bytes
/
index.js
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
33
34
35
36
37
#!/usr/bin/env node
const check = (minver) => {
let semver = process.versions.node.split('.');
if (semver[0] < minver) {
console.error(`ERROR: nodejs is too old. Version ${minver} or greater is required.`);
console.error(`ERROR: ${process.versions.node} installed`);
process.exit(1);
}
}
check(16);
(async function() {
const fs = require('fs');
const config = require('./lib/config');
const plutotv = require('./lib/plutotv');
const server = require('./lib/server');
config.loadConfig();
const port = config.get('port');
const refresh = config.get('refresh');
if (refresh && refresh < 3600) {
console.error("ERROR: please set refresh interval to be at least 3600 seconds");
process.exit(1);
}
if (port && refresh) {
setInterval(() => plutotv.process(config), refresh * 1000);
server.serve(config);
} else if (port) {
server.serve(config);
} else {
await plutotv.process(config);
}
})();