This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
server.js
87 lines (75 loc) · 1.83 KB
/
server.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Module Dependencies
*/
const express = require('express');
const path = require('path');
const { exec } = require('child_process');
/**
* Server Settings
*/
var app = express();
var port = 8000;
app.set('port', port);
/**
* Serving Static Files
*/
app.use(express.static(path.join(__dirname, 'site/html')));
app.use('/server/vital', express.static(path.join(__dirname, 'vital/public')));
app.use('/pages/', express.static(path.join(__dirname, 'vital/pages')));
/**
* Handling 404 Errors and Displaying 404 Page
*/
app.use(function (req, res, next) {
res.status(404);
res.sendFile(path.join(__dirname, 'vital', '404.html'));
});
/**
* Server listening
*/
app.listen(app.get('port'), function () {
console.log(`
Now listening on port ${port}
Go to http://localhost:${port}
`);
});
/**
* TODO: Add the description of this function
* [exec description]
* @param {[type]} error [description]
* @param {[type]} stdout [description]
* @param {[type]} stderr [description]
*/
exec('node index.js', (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
/**
* TODO: Add the description of this function
* [site description]
* [exec description]
* @param {[type]} error [description]
* @param {[type]} stdout [description]
* @param {[type]} stderr [description]
*/
function site() {
exec('npm run convert', (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
}
site();
setInterval(site, 600000);