Authored by 姜枫

处理node 状态查询失败

@@ -10,7 +10,7 @@ const Server = models.Server; @@ -10,7 +10,7 @@ const Server = models.Server;
10 const ws = require('../../lib/ws'); 10 const ws = require('../../lib/ws');
11 11
12 const monit = { 12 const monit = {
13 - node: function (projectId, hosts) { 13 + node: function (project, hosts) {
14 hosts.forEach((host) => { 14 hosts.forEach((host) => {
15 var obj = { 15 var obj = {
16 'total': 0, 16 'total': 0,
@@ -41,14 +41,14 @@ const monit = { @@ -41,14 +41,14 @@ const monit = {
41 }).catch(function (err) { 41 }).catch(function (err) {
42 obj.errmsg = '获取监控状态失败' 42 obj.errmsg = '获取监控状态失败'
43 }).finally(function () { 43 }).finally(function () {
44 - ws.broadcast(`/monit/${projectId}`, { 44 + ws.broadcast(`/monit/${project._id}`, {
45 host: host, 45 host: host,
46 monitdata: obj 46 monitdata: obj
47 }); 47 });
48 }); 48 });
49 }); 49 });
50 }, 50 },
51 - php: function(projectId, hosts) { 51 + php: function(project, hosts) {
52 if (!_.isArray(hosts)) { 52 if (!_.isArray(hosts)) {
53 return; 53 return;
54 } 54 }
@@ -67,7 +67,7 @@ const monit = { @@ -67,7 +67,7 @@ const monit = {
67 console.log(err); 67 console.log(err);
68 } else { 68 } else {
69 stream.on('close', () => { 69 stream.on('close', () => {
70 - ws.broadcast(`/monit/${projectId}`, { 70 + ws.broadcast(`/monit/${project._id}`, {
71 host: host, 71 host: host,
72 monitdata: obj 72 monitdata: obj
73 }); 73 });
@@ -437,9 +437,9 @@ const p = { @@ -437,9 +437,9 @@ const p = {
437 } 437 }
438 438
439 if (project.type === 'php') { 439 if (project.type === 'php') {
440 - monit.php(projectId, hosts); 440 + monit.php(project, hosts);
441 } else { 441 } else {
442 - monit.node(projectId, hosts); 442 + monit.node(project, hosts);
443 } 443 }
444 ctx.body = { 444 ctx.body = {
445 code: 200 445 code: 200
@@ -94,7 +94,7 @@ @@ -94,7 +94,7 @@
94 eventBind(); 94 eventBind();
95 95
96 $("#table-servers").DataTable({ 96 $("#table-servers").DataTable({
97 - pageLength: 5, 97 + pageLength: 20,
98 retrieve: true, 98 retrieve: true,
99 responsive: true, 99 responsive: true,
100 searching: false 100 searching: false