Commit 9ecf815f002a08ac4ac4323ae0680d684dce0a2e
1 parent
b30a7134
Exists in
master
and in
1 other branch
adicionado arquivo de configuracao e um modulo de acesso
Showing
3 changed files
with
72 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
1 | + | ||
2 | +var exports = module.exports = {}; | ||
3 | +var fs = require('fs'); | ||
4 | + | ||
5 | +var params_box = JSON.parse(fs.readFileSync('./config/params_box.json', 'utf8')); | ||
6 | + | ||
7 | +exports.getParamsBox = function () { | ||
8 | + return params_box; | ||
9 | +}; | ||
10 | + | ||
11 | +exports.getConfig = function (name) { | ||
12 | + return params_box[name]; | ||
13 | +}; | ||
14 | + | ||
15 | +exports.getServiceType = function () { | ||
16 | + return this.getConfig("service-type"); | ||
17 | +}; | ||
18 | + | ||
19 | +exports.getCheckInterval = function () { | ||
20 | + return this.getConfig("check-interval"); | ||
21 | +}; | ||
22 | + | ||
23 | +exports.getPaths = function () { | ||
24 | + // path vem um array, mas atualmente so existe um valor | ||
25 | + return this.getConfig("path")[0]; | ||
26 | +}; | ||
27 | + | ||
28 | +exports.getLogByName = function (name) { | ||
29 | + var paths = this.getPaths(); | ||
30 | + return paths[name + '-log']; | ||
31 | +}; | ||
32 | + | ||
33 | +exports.getServiceLogPath = function () { | ||
34 | + return this.getLogByName('service'); | ||
35 | +}; | ||
36 | +exports.getStatisticsLogPath = function () { | ||
37 | + return this.getLogByName('statistics'); | ||
38 | +}; | ||
39 | +exports.getErrorLogPath = function () { | ||
40 | + return this.getLogByName('error'); | ||
41 | +}; | ||
42 | +exports.getCapacityLogPath = function () { | ||
43 | + return this.getLogByName('capacity'); | ||
44 | +}; |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +{ | ||
2 | + "service-type": "3", | ||
3 | + "check-interval": "1", | ||
4 | + "identification": [ | ||
5 | + { | ||
6 | + "IP": "127.0.1.1", | ||
7 | + "hostname": "cielly-FCG", | ||
8 | + "maintainer": "Equipe Cloud", | ||
9 | + "description": "Machine for testes purposes only.", | ||
10 | + "id": "123456" | ||
11 | + } | ||
12 | + ], | ||
13 | + "load-balance": "150.165.205.85", | ||
14 | + "path": [ | ||
15 | + { | ||
16 | + "service-log": "/home/user/.vlibras-config/logs/service", | ||
17 | + "statistics-log": "/home/user/.vlibras-config/logs/statistics", | ||
18 | + "error-log": "/home/user/.vlibras-config/logs/error", | ||
19 | + "capacity-log": "/home/user/.vlibras-config/logs/capacity" | ||
20 | + } | ||
21 | + ], | ||
22 | + "exclusivity": "0", | ||
23 | + "report-interval": "5", | ||
24 | + "storage": "150.165.205.69", | ||
25 | + "qd-server-addr": "150.165.204.23" | ||
26 | +} |
server.js
@@ -15,6 +15,7 @@ var util = require('util'); | @@ -15,6 +15,7 @@ var util = require('util'); | ||
15 | var app = express(); | 15 | var app = express(); |
16 | var Request = require('./db/schemas/request').init(mongoose); | 16 | var Request = require('./db/schemas/request').init(mongoose); |
17 | var db = require('./db/api'); | 17 | var db = require('./db/api'); |
18 | +var config = require('./config/main.js'); | ||
18 | 19 | ||
19 | app.use(express.static(path.join(__dirname, '/videos'))); | 20 | app.use(express.static(path.join(__dirname, '/videos'))); |
20 | app.use(express.bodyParser({ keepExtensions: true, uploadDir: path.join(__dirname, '/uploads') })); | 21 | app.use(express.bodyParser({ keepExtensions: true, uploadDir: path.join(__dirname, '/uploads') })); |
@@ -31,7 +32,7 @@ app.post('/api', function(req, res) { | @@ -31,7 +32,7 @@ app.post('/api', function(req, res) { | ||
31 | 32 | ||
32 | /* Verifica se o paramêtro [servico] possui algum valor */ | 33 | /* Verifica se o paramêtro [servico] possui algum valor */ |
33 | if (req.body.servico !== '') { | 34 | if (req.body.servico !== '') { |
34 | - /* Verifica qual é o Tipo de Serviço fornecido */ | 35 | + /* Verifica qual é o Tipo de Serviço fornecido */ |
35 | switch(req.body.servico) { | 36 | switch(req.body.servico) { |
36 | /* Tipo de Serviço: Texto */ | 37 | /* Tipo de Serviço: Texto */ |
37 | case 'texto': | 38 | case 'texto': |