Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
10d632a2
Commit
10d632a2
authored
Mar 19, 2014
by
jsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add heartbeat endpoint
parent
4960adbf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
app.rb
+27
-0
No files found.
app.rb
View file @
10d632a2
...
...
@@ -170,3 +170,30 @@ end
CommentService
.
blocked_hashes
=
Content
.
mongo_session
[
:blocked_hash
].
find
.
select
(
hash:
1
).
each
.
map
{
|
d
|
d
[
"hash"
]}
get
'/heartbeat'
do
t1
=
Time
.
now
# any expected config / environment variables are set to sane values
# TODO: is there anything else applicable to check wrt config?
# mongo is reachable and ready to handle requests
db
=
Mongoid
::
Sessions
.
default
res
=
db
.
command
(
isMaster:
1
)
if
res
[
"ismaster"
]
!=
true
or
Integer
(
res
[
"ok"
])
!=
1
error
500
,
res
.
to_json
end
# E_S is reachable and ready to handle requests
res
=
Tire
::
Configuration
.
client
.
get
Tire
::
Configuration
.
url
es_status
=
JSON
.
parse
res
.
body
if
es_status
[
"ok"
]
!=
true
or
es_status
[
"status"
]
!=
200
error
500
,
res
.
to_json
end
status
=
{
"last_post_created"
=>
db
[
:contents
].
find
().
sort
(
_id:
-
1
).
limit
(
1
).
one
[
"created_at"
],
"total_posts"
=>
db
[
:contents
].
find
.
count
,
"total_users"
=>
db
[
:contents
].
find
.
count
,
"elapsed_time"
=>
Time
.
now
-
t1
}
JSON
.
generate
(
status
)
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment