Skip to content

Commit

Permalink
馃拲 Fix constant port
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalWilinski committed Aug 17, 2016
1 parent af7c56f commit d30faec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ <h1 id="rpsStat">-</h1>
Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)";
Chart.defaults.global.elements.line.borderWidth = 2;

var socket = io('http://' + window.location.hostname + ':41338');
var socket = io('http://' + window.location.hostname + ':{{port}}');
var defaultSpan = 0;
var spans = [];

Expand Down
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(function () {
'use strict';

const fs = require('fs');
const path = require('path');
const os = require('os');
const onHeaders = require('on-headers');
Expand Down Expand Up @@ -81,6 +82,16 @@

const io = require('socket.io')(config.socketPort);

fs.readFile(path.join(__dirname, 'index.html'), 'utf8', (err,data) => {
if (err) throw new Error(err);

var result = data.replace(/{{port}}/g, config.socketPort);

fs.writeFile(path.join(__dirname, 'index.rendered.html'), result, 'utf8', (err) => {
if (err) throw new Error(err);
});
});

io.on('connection', (socket) => {
socket.emit('start', config.spans);

Expand All @@ -96,7 +107,7 @@
return (req, res, next) => {
const startTime = process.hrtime();
if (req.path === config.path) {
res.sendFile(path.join(__dirname + '/index.html'));
res.sendFile(path.join(__dirname + '/index.rendered.html'));
} else {
onHeaders(res, () => {
const diff = process.hrtime(startTime);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-status-monitor",
"version": "0.0.5",
"version": "0.0.6",
"description": "Monitoring for Express-based Node applications",
"main": "app.js",
"keywords": [
Expand Down

0 comments on commit d30faec

Please sign in to comment.