d30faec1 by Rafal Wilinski

:ring: Fix constant port

1 parent af7c56fb
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
136 Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)"; 136 Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)";
137 Chart.defaults.global.elements.line.borderWidth = 2; 137 Chart.defaults.global.elements.line.borderWidth = 2;
138 138
139 var socket = io('http://' + window.location.hostname + ':41338'); 139 var socket = io('http://' + window.location.hostname + ':{{port}}');
140 var defaultSpan = 0; 140 var defaultSpan = 0;
141 var spans = []; 141 var spans = [];
142 142
......
1 (function () { 1 (function () {
2 'use strict'; 2 'use strict';
3 3
4 const fs = require('fs');
4 const path = require('path'); 5 const path = require('path');
5 const os = require('os'); 6 const os = require('os');
6 const onHeaders = require('on-headers'); 7 const onHeaders = require('on-headers');
...@@ -81,6 +82,16 @@ ...@@ -81,6 +82,16 @@
81 82
82 const io = require('socket.io')(config.socketPort); 83 const io = require('socket.io')(config.socketPort);
83 84
85 fs.readFile(path.join(__dirname, 'index.html'), 'utf8', (err,data) => {
86 if (err) throw new Error(err);
87
88 var result = data.replace(/{{port}}/g, config.socketPort);
89
90 fs.writeFile(path.join(__dirname, 'index.rendered.html'), result, 'utf8', (err) => {
91 if (err) throw new Error(err);
92 });
93 });
94
84 io.on('connection', (socket) => { 95 io.on('connection', (socket) => {
85 socket.emit('start', config.spans); 96 socket.emit('start', config.spans);
86 97
...@@ -96,7 +107,7 @@ ...@@ -96,7 +107,7 @@
96 return (req, res, next) => { 107 return (req, res, next) => {
97 const startTime = process.hrtime(); 108 const startTime = process.hrtime();
98 if (req.path === config.path) { 109 if (req.path === config.path) {
99 res.sendFile(path.join(__dirname + '/index.html')); 110 res.sendFile(path.join(__dirname + '/index.rendered.html'));
100 } else { 111 } else {
101 onHeaders(res, () => { 112 onHeaders(res, () => {
102 const diff = process.hrtime(startTime); 113 const diff = process.hrtime(startTime);
......
1 { 1 {
2 "name": "express-status-monitor", 2 "name": "express-status-monitor",
3 "version": "0.0.5", 3 "version": "0.0.6",
4 "description": "Monitoring for Express-based Node applications", 4 "description": "Monitoring for Express-based Node applications",
5 "main": "app.js", 5 "main": "app.js",
6 "keywords": [ 6 "keywords": [
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!