Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jabis Sevón
/
esm
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d6327597
authored
2016-08-18 10:07:39 +0200
by
Rafal Wilinski
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added HTTPS support, port deprecated
1 parent
3a5053e5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
23 deletions
README.md
index.html
index.js
package.json
README.md
View file @
d632759
...
...
@@ -16,8 +16,6 @@ Monitor can be configured by passing options object into `expressMonitor` constr
Default config:
```
path: '/status',
socketPort: 41338, // Port for Socket.io communication,
useHttps: false, // Force HTTPS protocol instead of HTTP
spans: [{
interval: 1, // Every second
retention: 60 // Keep 60 datapoints in memory
...
...
index.html
View file @
d632759
...
...
@@ -136,7 +136,7 @@
Chart
.
defaults
.
global
.
elements
.
line
.
borderColor
=
"rgba(0,0,0,0.9)"
;
Chart
.
defaults
.
global
.
elements
.
line
.
borderWidth
=
2
;
var
socket
=
io
(
'{{protocol}}'
+
'://'
+
window
.
location
.
hostname
+
':{{port}}'
);
var
socket
=
io
(
location
.
protocol
+
'//'
+
location
.
hostname
+
':'
+
location
.
port
);
var
defaultSpan
=
0
;
var
spans
=
[];
...
...
index.js
View file @
d632759
...
...
@@ -6,11 +6,10 @@
const
os
=
require
(
'os'
);
const
onHeaders
=
require
(
'on-headers'
);
const
pidusage
=
require
(
'pidusage'
);
let
io
;
const
defaultConfig
=
{
socketPort
:
41338
,
path
:
'/status'
,
useHttps
:
false
,
spans
:
[{
interval
:
1
,
retention
:
60
...
...
@@ -73,29 +72,17 @@
config
.
path
=
defaultConfig
.
path
;
}
if
(
config
.
socketPort
===
undefined
||
!
config
instanceof
Number
)
{
config
.
socketPort
=
defaultConfig
.
socketPort
;
}
if
(
config
.
spans
===
undefined
||
!
config
instanceof
Array
)
{
config
.
spans
=
defaultConfig
.
spans
;
}
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
).
replace
(
/{{protocol}}/g
,
config
.
useHttps
?
'https'
:
'http'
);
return
(
req
,
res
,
next
)
=>
{
if
(
io
===
null
||
io
===
undefined
)
{
fs
.
writeFile
(
path
.
join
(
__dirname
,
'index.rendered.html'
),
result
,
'utf8'
,
(
err
)
=>
{
if
(
err
)
throw
new
Error
(
err
);
});
});
io
=
require
(
'socket.io'
)(
req
.
socket
.
server
);
io
.
on
(
'connection'
,
(
socket
)
=>
{
socket
.
emit
(
'start'
,
config
.
spans
);
socket
.
on
(
'change'
,
function
()
{
socket
.
emit
(
'start'
,
config
.
spans
);
});
});
...
...
@@ -104,11 +91,11 @@
span
.
responses
=
[];
setInterval
(()
=>
gatherOsMetrics
(
io
,
span
),
span
.
interval
*
1000
);
});
}
return
(
req
,
res
,
next
)
=>
{
const
startTime
=
process
.
hrtime
();
if
(
req
.
path
===
config
.
path
)
{
res
.
sendFile
(
path
.
join
(
__dirname
+
'/index.
rendered.
html'
));
res
.
sendFile
(
path
.
join
(
__dirname
+
'/index.html'
));
}
else
{
onHeaders
(
res
,
()
=>
{
const
diff
=
process
.
hrtime
(
startTime
);
...
...
package.json
View file @
d632759
{
"name"
:
"express-status-monitor"
,
"version"
:
"0.0.
8
"
,
"version"
:
"0.0.
9
"
,
"description"
:
"Monitoring for Express-based Node applications"
,
"main"
:
"app.js"
,
"keywords"
:
[
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment