main.js
2.05 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
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
88
89
90
var exports = module.exports = {};
var fs = require('fs');
var params_box = JSON.parse(fs.readFileSync('./config/params_box.json', 'utf8'));
exports.getParamsBox = function () {
return params_box;
};
exports.getConfig = function (name) {
return params_box[name];
};
exports.getServiceType = function () {
return this.getConfig("service-type");
};
exports.getCheckInterval = function () {
return this.getConfig("check-interval");
};
exports.getPaths = function () {
// path vem um array, mas atualmente so existe um valor
return this.getConfig("path")[0];
};
exports.getLogByName = function (name) {
var paths = this.getPaths();
return paths[name + '-log'];
};
exports.getServiceLogPath = function () {
return this.getLogByName('service');
};
exports.getStatisticsLogPath = function () {
return this.getLogByName('statistics');
};
exports.getErrorLogPath = function () {
return this.getLogByName('error');
};
exports.getCapacityLogPath = function () {
return this.getLogByName('capacity');
};
exports.isBloqueante = function () {
//1 para bloqueante, 2 para nao bloqueante e 3 pra aceitar os dois
return this.getServiceType() === 1;
};
exports.isNaoBloqueante = function () {
//1 para bloqueante, 2 para nao bloqueante e 3 pra aceitar os dois
return this.getServiceType() === 2;
};
exports.isAmbos = function () {
//1 para bloqueante, 2 para nao bloqueante e 3 pra aceitar os dois
return this.getServiceType() === 3;
};
exports.canRunOnBox = function (service) {
//1 para bloqueante, 2 para nao bloqueante e 3 pra aceitar os dois
var serviceType = parseInt(this.getServiceType());
switch(service) {
case 'texto':
return serviceType == 1 || serviceType == 3;
case 'ios':
return true;
case 'video':
return serviceType == 2 || serviceType == 3;
case 'legenda':
return serviceType == 1 || serviceType == 3;
case 'video-legenda':
return serviceType == 2 || serviceType == 3;
case 'videornp':
return serviceType == 2 || serviceType == 3;
default:
return false;
}
};