diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d5ee394 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + upload: + name: Upload + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + server-id: github + settings-path: ${{ github.workspace }} + + - name: Build jar + run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean package + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build rpm + run: cd rpm/ && mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= package -f rpm.pom.xml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Attach jar and rpm to release + uses: softprops/action-gh-release@v1 + with: + files: | + rpm/target/rpm/com.teragrep-rlp_11/RPMS/noarch/com.teragrep-rlp_11-*.rpm + target/rlp_11-jar-with-dependencies.jar diff --git a/.gitignore b/.gitignore index 92322c4..3e7ba63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ target/ +rpm/target/ diff --git a/pom.xml b/pom.xml index 5612e9c..f941911 100644 --- a/pom.xml +++ b/pom.xml @@ -510,12 +510,15 @@ eclipse-java-formatter.xml src/main/assembly/jar-with-dependencies.xml - etc/*.properties + src/test/resources/*.properties src/main/resources/log4j2.xml src/test/resources/log4j2-test.xml README.adoc + + rpm/rpm.pom.xml + rpm/src/** diff --git a/rpm/rpm.pom.xml b/rpm/rpm.pom.xml new file mode 100644 index 0000000..2c83a22 --- /dev/null +++ b/rpm/rpm.pom.xml @@ -0,0 +1,173 @@ + + + rpm + 4.0.0 + rlp_11 + ${revision}${sha1}${changelist} + rlp_11 + rlp_11 + com.teragrep + + UTF-8 + 0.0.1 + -SNAPSHOT + + + + ${project.basedir}/target + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.2 + + true + + + + maven-enforcer-plugin + 3.5.0 + + + enforce + none + + + enforce-maven + + enforce + + + + + 3.6.3 + + + + + + + + org.codehaus.mojo + rpm-maven-plugin + 2.3.0 + true + + + default-rpm + + rpm + + package + + + + ${project.groupId}-${project.artifactId} + ${project.groupId}-${project.artifactId} + ${project.version} + ${env.BUILD_ID} + AGPL + Teragrep rlp_11 + https://teragrep.com/ + Teragrep <servicedesk@teragrep.com> + Teragrep/rlp_11 + ${project.groupId}-${project.artifactId} + false + srv-rlp_11 + srv-rlp_11 + 0644 + 0755 + + + /usr/lib/systemd/system + false + + + src/usr/lib/systemd/system + + + + + /opt/teragrep/${project.artifactId}/etc + true + 755 + + + /opt/teragrep/${project.artifactId}/etc + noreplace + false + srv-rlp_11 + srv-rlp_11 + false + + + ${project.basedir}/src/opt/teragrep/rlp_11/etc/log4j2.xml + + + ${project.basedir}/src/opt/teragrep/rlp_11/etc/rlp_11.properties + + + + + /opt/teragrep/${project.artifactId}/lib + true + 755 + + + /opt/teragrep/${project.artifactId}/lib + false + 755 + 755 + srv-rlp_11 + srv-rlp_11 + false + + + ${project.basedir}/../target/rlp_11-jar-with-dependencies.jar + rlp_11.jar + + + + + + java-11-openjdk-headless + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.3 + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + default-compile + compile + + compile + + + true + + + + + + + diff --git a/rpm/src/opt/teragrep/rlp_11/etc/log4j2.xml b/rpm/src/opt/teragrep/rlp_11/etc/log4j2.xml new file mode 100644 index 0000000..959d7dc --- /dev/null +++ b/rpm/src/opt/teragrep/rlp_11/etc/log4j2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/etc/rlp_11.properties b/rpm/src/opt/teragrep/rlp_11/etc/rlp_11.properties similarity index 100% rename from etc/rlp_11.properties rename to rpm/src/opt/teragrep/rlp_11/etc/rlp_11.properties diff --git a/rpm/src/usr/lib/systemd/system/rlp_11.service b/rpm/src/usr/lib/systemd/system/rlp_11.service new file mode 100644 index 0000000..8330f1b --- /dev/null +++ b/rpm/src/usr/lib/systemd/system/rlp_11.service @@ -0,0 +1,15 @@ +[Unit] +Description=com.teragrep.rlp_11 +ConditionPathExists=/opt/teragrep/rlp_11/etc/rlp_11.properties +ConditionPathExists=/opt/teragrep/rlp_11/etc/log4j2.xml + +[Service] +ExecStart=/usr/lib/jvm/jre-11-openjdk/bin/java \ + -DconfigurationPath=/opt/teragrep/rlp_11/etc/rlp_11.properties \ + -Dlog4j2.configurationFile=file:/opt/teragrep/rlp_11/etc/log4j2.xml \ + -jar /opt/teragrep/rlp_11/lib/rlp_11.jar +User=srv-rlp_11 +WorkingDirectory=/opt/teragrep/rlp_11 + +[Install] +WantedBy=multi-user.target diff --git a/rpm/src/usr/lib/systemd/system/rlp_11@.service b/rpm/src/usr/lib/systemd/system/rlp_11@.service new file mode 100644 index 0000000..2a11f2f --- /dev/null +++ b/rpm/src/usr/lib/systemd/system/rlp_11@.service @@ -0,0 +1,15 @@ +[Unit] +Description=com.teragrep.rlp_11 instance %I +ConditionPathExists=/opt/teragrep/rlp_11/etc/rlp_11.%I.properties +ConditionPathExists=/opt/teragrep/rlp_11/etc/log4j2.%I.xml + +[Service] +ExecStart=/usr/lib/jvm/jre-11-openjdk/bin/java \ + -DconfigurationPath=/opt/teragrep/rlp_11/etc/rlp_11.%I.properties \ + -Dlog4j2.configurationFile=file:/opt/teragrep/rlp_11/etc/log4j2.%I.xml \ + -jar /opt/teragrep/rlp_11/lib/rlp_11.jar +User=srv-rlp_11 +WorkingDirectory=/opt/teragrep/rlp_11 + +[Install] +WantedBy=multi-user.target diff --git a/src/test/java/com/teragrep/rlp_11/ConnectionTest.java b/src/test/java/com/teragrep/rlp_11/ConnectionTest.java index 86bc4d7..02621b7 100644 --- a/src/test/java/com/teragrep/rlp_11/ConnectionTest.java +++ b/src/test/java/com/teragrep/rlp_11/ConnectionTest.java @@ -124,7 +124,7 @@ public void stopServer() { @Test public void connectToServerTest() { Map map = Assertions - .assertDoesNotThrow(() -> new PathConfiguration("etc/rlp_11.properties").asMap()); + .assertDoesNotThrow(() -> new PathConfiguration("src/test/resources/connect.properties").asMap()); final ProbeConfiguration probeConfiguration = new ProbeConfiguration(map); final RecordFactory recordFactory = new RecordFactory("localhost", "rlp_11", "rlp_11"); final TargetConfiguration targetConfiguration = new TargetConfiguration(map); diff --git a/src/test/resources/connect.properties b/src/test/resources/connect.properties new file mode 100644 index 0000000..52a88ba --- /dev/null +++ b/src/test/resources/connect.properties @@ -0,0 +1,24 @@ +# Metrics reporting name. Arbitrary string, only used for reporting purposes +metrics.name=target +# Metrics window size +metrics.window=10000 +# Metrics report interval, in seconds +metrics.interval=60 + +# Delay between sending records, in milliseconds +probe.interval=1000 + +# Prometheus endpoint port +prometheus.port=8080 + +# Appname used in RELP record +record.appname=rlp_11 +# Hostname used in RELP record +record.hostname=rlp_11 + +# RELP Server target address +target.hostname=127.0.0.1 +# Relp Server target port +target.port=12345 +# RELP Server reconnect interval, in milliseconds +target.reconnectinterval=1000