박은주

Add Scheduler

Showing 1 changed file with 9 additions and 2 deletions
1 const http = require('http'); 1 const http = require('http');
2 -const express = require('express') 2 +const express = require('express');
3 const fs = require('fs'); 3 const fs = require('fs');
4 -const path = require('path'); 4 +const schedule = require('node-schedule');
5 +const spawn = require('child_process').spawn;
5 const { rawListeners } = require('process'); 6 const { rawListeners } = require('process');
6 var port = 23023; 7 var port = 23023;
7 8
...@@ -15,6 +16,12 @@ app.engine('html', require('ejs').renderFile); ...@@ -15,6 +16,12 @@ app.engine('html', require('ejs').renderFile);
15 16
16 app.use(express.static(__dirname + '/static')); 17 app.use(express.static(__dirname + '/static'));
17 18
19 +function update() {
20 + console.log('Updating . . .');
21 + spawn('python3', ["run.py"])
22 +}
23 +setInterval(update, 1000 * 60 * 60 * 3)
24 +
18 var server = http.createServer(app).listen(port, function(){ 25 var server = http.createServer(app).listen(port, function(){
19 console.log("Server Running . . ."); 26 console.log("Server Running . . .");
20 }) 27 })
...\ No newline at end of file ...\ No newline at end of file
......