Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
521e2aad
Commit
521e2aad
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
don't log calls to __heartbeat__ closes #537
parent
65d1f57a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/browserid
+9
-6
9 additions, 6 deletions
bin/browserid
lib/heartbeat.js
+20
-9
20 additions, 9 deletions
lib/heartbeat.js
with
29 additions
and
15 deletions
bin/browserid
+
9
−
6
View file @
521e2aad
...
...
@@ -71,6 +71,8 @@ if (!config.get('keysigner_url')) {
process
.
exit
(
1
);
}
// NOTE: ordering is important in this file. Pay attention
function
router
(
app
)
{
app
.
set
(
"
views
"
,
path
.
join
(
__dirname
,
"
..
"
,
"
resources
"
,
"
views
"
));
...
...
@@ -171,12 +173,6 @@ function router(app) {
// register all the WSAPI handlers
wsapi
.
setup
(
app
);
// setup health check / heartbeat
heartbeat
.
setup
(
app
,
function
(
cb
)
{
// let's check stuff! first the heartbeat of our keysigner
heartbeat
.
check
(
config
.
get
(
'
keysigner_url
'
),
cb
);
});
// the public key
app
.
get
(
"
/pk
"
,
function
(
req
,
res
)
{
res
.
json
(
config
.
get
(
'
public_key
'
).
toSimpleObject
());
...
...
@@ -203,6 +199,13 @@ function router(app) {
});
};
// #1 - Setup health check / heartbeat middleware.
// This is in front of logging on purpose. see issue #537
heartbeat
.
setup
(
app
,
function
(
cb
)
{
// let's check stuff! first the heartbeat of our keysigner
heartbeat
.
check
(
config
.
get
(
'
keysigner_url
'
),
cb
);
});
// request to logger, dev formatted which omits personal data in the requests
app
.
use
(
express
.
logger
({
format
:
config
.
get
(
'
express_log_format
'
),
...
...
This diff is collapsed.
Click to expand it.
lib/heartbeat.js
+
20
−
9
View file @
521e2aad
const
urlparse
=
require
(
'
urlparse
'
);
const
urlparse
=
require
(
'
urlparse
'
),
logger
=
require
(
'
./logging.js
'
).
logger
;
// the path that heartbeats live at
exports
.
path
=
'
/__heartbeat__
'
;
// a helper function to set up a heartbeat check
exports
.
setup
=
function
(
app
,
cb
)
{
app
.
get
(
exports
.
path
,
function
(
req
,
res
)
{
function
ok
(
yeah
)
{
res
.
writeHead
(
yeah
?
200
:
500
);
res
.
write
(
yeah
?
'
ok
'
:
'
not ok
'
);
res
.
end
();
app
.
use
(
function
(
req
,
res
,
next
)
{
if
(
req
.
method
===
'
GET
'
&&
req
.
path
===
exports
.
path
)
{
function
ok
(
yeah
)
{
res
.
writeHead
(
yeah
?
200
:
500
);
res
.
write
(
yeah
?
'
ok
'
:
'
not ok
'
);
res
.
end
();
}
try
{
if
(
cb
)
cb
(
ok
);
else
ok
(
true
);
}
catch
(
e
)
{
logger
.
error
(
"
Exception caught in heartbeat handler:
"
+
e
.
toString
());
ok
(
false
);
}
}
else
{
return
next
();
}
if
(
cb
)
cb
(
ok
);
else
ok
(
true
);
});
};
...
...
@@ -35,4 +46,4 @@ exports.check = function(url, cb) {
logger
.
error
(
"
can't communicate with
"
+
shortname
+
"
. fatal:
"
+
e
);
cb
(
false
);
});
};
\ No newline at end of file
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment