Skip to content

Commit

Permalink
[ALS-7751] Java Opts can now be passed to docker container (#52)
Browse files Browse the repository at this point in the history
* Add MemoryCheck service for monitoring max heap memory
* Replace System.out with SLF4J logger in MemoryCheck

Updated the MemoryCheck class to use SLF4J logger instead of System.out for logging max heap memory. This enhances logging consistency and allows better integration with logging frameworks.
  • Loading branch information
Gcolon021 authored Nov 4, 2024
1 parent 1dd78ac commit de6d382
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ ENV DATASOURCE_USERNAME=${DATASOURCE_USERNAME}
ENV SPRING_PROFILE=${SPRING_PROFILE}

# Default to no profile
ENTRYPOINT java $DEBUG_VARS $PROXY_VARS -Xmx8192m -jar /dictionary.jar --spring.profiles.active=${SPRING_PROFILE:-}
ENTRYPOINT java $DEBUG_VARS $PROXY_VARS -Xmx8192m ${JAVA_OPTS} -jar /dictionary.jar --spring.profiles.active=${SPRING_PROFILE:-}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package edu.harvard.dbmi.avillach.dictionary.memory;

import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MemoryCheck {

private static final Logger LOG = LoggerFactory.getLogger(MemoryCheck.class);

@PostConstruct
public void checkMemory() {
long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024);
LOG.info("Max Heap Memory (Xmx): {} MB", maxMemory);
}

}

0 comments on commit de6d382

Please sign in to comment.