This commit is contained in:
root
2025-09-21 18:43:30 +05:00
parent dfaebf81b8
commit 9ecfb5c904
3 changed files with 25 additions and 8 deletions
+2 -2
View File
@@ -25,5 +25,5 @@ RUN chown appuser:appgroup app.jar
# Switch to the non-root user
USER appuser
# Run the jar file with JVM flags for heap dump generation on OutOfMemoryError
ENTRYPOINT ["java", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/dumps/heap.hprof", "-jar", "app.jar"]
# Run the jar file with JVM flags for heap dump generation on OutOfMemoryError and headless mode
ENTRYPOINT ["java", "-Djava.awt.headless=true", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/dumps/heap.hprof", "-jar", "app.jar"]
@@ -325,14 +325,28 @@ public class ReportGenerationService {
}
private byte[] buildSentimentChart(Map<String, Long> sentiment) {
DefaultPieDataset<String> dataset = new DefaultPieDataset<>();
for (Map.Entry<String, Long> e : sentiment.entrySet()) {
dataset.setValue(e.getKey(), e.getValue());
}
JFreeChart chart = ChartFactory.createPieChart("Sentiment", dataset, true, false, false);
try {
return EncoderUtil.encode(chart.createBufferedImage(800, 500), ImageFormat.PNG);
// Disable font rendering to avoid Docker font issues
System.setProperty("java.awt.headless", "true");
DefaultPieDataset<String> dataset = new DefaultPieDataset<>();
for (Map.Entry<String, Long> e : sentiment.entrySet()) {
dataset.setValue(e.getKey(), e.getValue());
}
JFreeChart chart = ChartFactory.createPieChart("Sentiment", dataset, true, false, false);
// Create buffered image with headless graphics
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(800, 500,
java.awt.image.BufferedImage.TYPE_INT_RGB);
java.awt.Graphics2D g2d = image.createGraphics();
g2d.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
chart.draw(g2d, new java.awt.geom.Rectangle2D.Double(0, 0, 800, 500));
g2d.dispose();
return EncoderUtil.encode(image, ImageFormat.PNG);
} catch (Exception ex) {
// Return null if chart generation fails
return null;
}
}
@@ -3,6 +3,9 @@ minio.endpoint=http://92.38.48.166:9000
minio.access-key=z9HhZTjzhVWqw3D20u7q
minio.secret-key=lhhHtJow1b10z6EZRMTQIU1tsKkoaxCVpSypCrcb
minio.bucket-name=konturai
# Headless mode for chart generation in Docker
java.awt.headless=true
spring.application.name=parser
# MongoDB Configuration