|
|
@ -31,18 +31,17 @@ if (os.platform() === 'linux') { |
|
|
|
|
|
|
|
// GUI APP settings and starting gui on address http://120.0.0.1:17777
|
|
|
|
var shepherd = require('./routes/shepherd'), |
|
|
|
guiapp = express(); |
|
|
|
guiapp = express(), |
|
|
|
appConfig = shepherd.loadLocalConfig(); // load app config
|
|
|
|
|
|
|
|
guiapp.use(function(req, res, next) { |
|
|
|
res.header("Access-Control-Allow-Origin", "http://127.0.0.1:17777"); |
|
|
|
res.header("Access-Control-Allow-Headers", "X-Requested-With"); |
|
|
|
res.header("Access-Control-Allow-Credentials", "true"); |
|
|
|
res.header("Access-Control-Allow-Headers", "Content-Type"); |
|
|
|
res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS"); |
|
|
|
res.header('Access-Control-Allow-Origin', 'http://127.0.0.1:' + appConfig.iguanaAppPort); |
|
|
|
res.header('Access-Control-Allow-Headers', 'X-Requested-With'); |
|
|
|
res.header('Access-Control-Allow-Credentials', 'true'); |
|
|
|
res.header('Access-Control-Allow-Headers', 'Content-Type'); |
|
|
|
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS'); // TODO: limit allowed methods
|
|
|
|
next(); |
|
|
|
}); |
|
|
|
|
|
|
|
var appConfig = shepherd.loadLocalConfig(); // load app config
|
|
|
|
}); |
|
|
|
|
|
|
|
// preload.js
|
|
|
|
const _setImmediate = setImmediate, |
|
|
@ -69,7 +68,6 @@ guiapp.get('/', function (req, res) { |
|
|
|
|
|
|
|
var guipath = path.join(__dirname, '/gui'); |
|
|
|
guiapp.use('/gui', express.static(guipath)); |
|
|
|
|
|
|
|
guiapp.use('/shepherd', shepherd); |
|
|
|
|
|
|
|
/*if (cluster.isMaster && process.env.NODE_ENV !== "development") { |
|
|
@ -84,18 +82,19 @@ console.log(cluster) |
|
|
|
console.log('guiapp listening on port ' + appConfig.iguanaAppPort + '!'); |
|
|
|
});*/ |
|
|
|
|
|
|
|
var server = require('http').createServer(guiapp); |
|
|
|
var io = require('socket.io').listen(server); |
|
|
|
var server = require('http').createServer(guiapp), |
|
|
|
io = require('socket.io').listen(server); |
|
|
|
|
|
|
|
server.listen(appConfig.iguanaAppPort, function() { |
|
|
|
console.log('guiapp and sockets.io are listening on port ' + appConfig.iguanaAppPort + '!'); |
|
|
|
}); |
|
|
|
|
|
|
|
io.set('origins', 'http://127.0.0.1:17777'); |
|
|
|
io.set('origins', 'http://127.0.0.1:17777'); // set origin
|
|
|
|
|
|
|
|
io.on('connection', function(client) { |
|
|
|
console.log('EDEX GUI is connected...'); |
|
|
|
|
|
|
|
client.on('event', function(data) { |
|
|
|
client.on('event', function(data) { // listen for client requests
|
|
|
|
console.log(data); |
|
|
|
}); |
|
|
|
client.on('disconnect', function(data) { |
|
|
@ -107,7 +106,7 @@ io.on('connection', function(client) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
shepherd.setIO(io); |
|
|
|
shepherd.setIO(io); // pass sockets object to shepherd router
|
|
|
|
|
|
|
|
//io.emit('an event sent to all connected clients');
|
|
|
|
|
|
|
|