Skip to content

Commit

Permalink
Healthcheck fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Dec 14, 2023
1 parent 0f643bd commit 9cf70ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN if [ -f "/ros_entrypoint.sh" ]; then \
fi

COPY ./healthcheck.sh /
HEALTHCHECK --interval=5s --timeout=2s --start-period=5s --retries=4 \
HEALTHCHECK --interval=2s --timeout=1s --start-period=20s --retries=1 \
CMD ["/healthcheck.sh"]

# Ensure LIDAR stops spinning on container shutdown
Expand Down
6 changes: 3 additions & 3 deletions healthcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

using namespace std::chrono_literals;

#define LOOP_PERIOD 2s
#define MSG_VALID_TIME 5s
#define LOOP_PERIOD 500ms
#define MSG_VALID_TIME 2s

std::chrono::steady_clock::time_point last_msg_time;

Expand All @@ -22,7 +22,7 @@ void healthy_check() {
std::chrono::steady_clock::time_point current_time =
std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed_time = current_time - last_msg_time;
bool is_msg_valid = elapsed_time.count() < MSG_VALID_TIME.count();
bool is_msg_valid = elapsed_time < MSG_VALID_TIME;

if (is_msg_valid) {
write_health_status("healthy");
Expand Down

0 comments on commit 9cf70ce

Please sign in to comment.