Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #2

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM openjdk:21
FROM openjdk:21-slim

WORKDIR .

COPY ./build/peppol-bis-billing-validator--runner.jar .

ENTRYPOINT ["java", "-Xmx512m", "-jar", "peppol-bis-billing-validator--runner.jar"]
ENTRYPOINT ["java", "-jar", "peppol-bis-billing-validator--runner.jar"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# peppol-bis-billing-validator
[![Generic badge](https://img.shields.io/badge/Version-0.1.0-important.svg)]()
[![Generic badge](https://img.shields.io/badge/Version-0.2.0-important.svg)]()
[![Generic badge](https://img.shields.io/badge/License-MIT-blue.svg)]()

## Introduction
Expand All @@ -23,6 +23,8 @@ XML.
image: 'easybill/peppol-bis-billing-validator:latest'
ports:
- '8081:8080'
environment:
JAVA_TOOL_OPTIONS: -Xmx512m
healthcheck:
test: curl --fail http://localhost:8081/health || exit 0
interval: 10s
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/io/github/easybill/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.annotations.QuarkusMain;
import java.nio.charset.StandardCharsets;

@QuarkusMain
public class Main {

public static void main(String[] args) throws Exception {
Main.printBannerText();
Quarkus.run(args);
}

private static void printBannerText() throws Exception {
try (var bannerStream = Main.class.getResourceAsStream("/banner.txt")) {
if (bannerStream == null) {
throw new Exception("could not read banner file");
}

System.out.println(
new String(bannerStream.readAllBytes(), StandardCharsets.UTF_8)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@OpenAPIDefinition(
info = @Info(
title = "Peppol Validator API",
version = "0.1.0",
version = "0.2.0",
contact = @Contact(
name = "easybill GmbH",
url = "https://github.com/easybill",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.easybill.Services.HealthCheck;

import jakarta.enterprise.context.ApplicationScoped;
import java.lang.management.ManagementFactory;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.HealthCheckResponseBuilder;
import org.eclipse.microprofile.health.Liveness;

@Liveness
@ApplicationScoped
public final class StatsHealthCheck implements HealthCheck {

@Override
public HealthCheckResponse call() {
HealthCheckResponseBuilder response = HealthCheckResponse.named(
"stats"
);

var osBean = ManagementFactory.getOperatingSystemMXBean();
var memBean = ManagementFactory.getMemoryMXBean();

return response
.up()
.withData("osName", osBean.getName())
.withData("osArch", osBean.getArch())
.withData(
"heapMemoryUsageMax",
memBean.getHeapMemoryUsage().getMax()
)
.withData(
"heapMemoryUsageCommitted",
memBean.getHeapMemoryUsage().getCommitted()
)
.withData(
"heapMemoryUsageUsed",
memBean.getHeapMemoryUsage().getUsed()
)
.build();
}
}
7 changes: 7 additions & 0 deletions src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

___. .__.__ .__
____ _____ _________.__.\_ |__ |__| | | |
_/ __ \\__ \ / ___< | | | __ \| | | | |
\ ___/ / __ \_\___ \ \___ | | \_\ \ | |_| |__
\___ >____ /____ >/ ____| |___ /__|____/____/
\/ \/ \/ \/ \/
Loading