-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartProxyServer.js
More file actions
36 lines (33 loc) · 1.11 KB
/
startProxyServer.js
File metadata and controls
36 lines (33 loc) · 1.11 KB
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
"use strict";
var spawn = require('child_process').exec;
var service = 'PROXY SERVER START SCRIPT';
var redisService = require('./server/service/redisService');
var log = function(service, level, message) {
var logMessage = {
level: level,
service: service,
pid: process.pid,
message: message
};
redisService.publish('log', logMessage);
};
var startProxyServer = function() {
var proxy_child = spawn("sudo forever --minUptime 1000 --spinSleepTime 1000 server/proxyServer.js", function(error) {
if (error) {
log(service, 'error', 'PROXY SERVER ERROR: ' + error);
}
log(service, 'error', "PROXY SERVER EXITED");
});
proxy_child.stderr.on('data', function (data) {
console.log(data);
log(service, 'error', 'PROXY SERVER ERROR: ' + data);
});
proxy_child.stdout.on('data', function(data) {
log(service, 'info', 'PROXY SERVER: ' + data);
});
proxy_child.on('close', function(code) {
log(service, 'error', 'PROXY SERVER EXITED WITH CODE: ' + code);
startProxyServer();
});
}
startProxyServer();