Skip to content

Commit

Permalink
Fixes piranhacloud#3806 - Add MultiPiranha (piranhacloud#3822)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Jul 23, 2024
1 parent 9ea6288 commit d334ba7
Show file tree
Hide file tree
Showing 24 changed files with 1,506 additions and 18 deletions.
22 changes: 10 additions & 12 deletions dist/platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
<portNames>
<portName>httpPort</portName>
<portName>httpPort2</portName>
<portName>httpsPort2</portName>
<portName>httpPort2b</portName>
<portName>httpPort3</portName>
<portName>httpPort3b</portName>
<portName>httpPort4</portName>
<portName>httpPort4b</portName>
</portNames>
</configuration>
</execution>
Expand All @@ -96,16 +100,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<httpPort2>${httpPort2}</httpPort2>
<httpsPort2>${httpsPort2}</httpsPort2>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand All @@ -125,7 +119,11 @@
<systemPropertyVariables>
<httpPort>${httpPort}</httpPort>
<httpPort2>${httpPort2}</httpPort2>
<httpsPort2>${httpsPort2}</httpsPort2>
<httpPort2b>${httpPort2b}</httpPort2b>
<httpPort3>${httpPort2}</httpPort3>
<httpPort3b>${httpPort2b}</httpPort3b>
<httpPort4>${httpPort2}</httpPort4>
<httpPort4b>${httpPort2b}</httpPort4b>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void testHttpPort2() throws Exception {
PlatformPiranha piranha = new PlatformPiranhaBuilder()
.extensionClass(PlatformExtension.class)
.httpPort(-1)
.httpsPort(Integer.parseInt(System.getProperty("httpsPort2")))
.httpsPort(Integer.parseInt(System.getProperty("httpPort2b")))
.build();
piranha.start();
Thread.sleep(5000);
Expand All @@ -99,13 +99,13 @@ void testHttpsPort2() throws Exception {
.extensionClass(PlatformExtension.class)
.httpsKeystoreFile("src/main/zip/etc/keystore.jks")
.httpsKeystorePassword("password")
.httpPort(8228)
.httpsPort(8338)
.httpPort(Integer.parseInt(System.getProperty("httpPort3")))
.httpsPort(Integer.parseInt(System.getProperty("httpPort3b")))
.build();
piranha.start();
Thread.sleep(5000);
SocketFactory factory = SSLSocketFactory.getDefault();
try (SSLSocket socket = (SSLSocket) factory.createSocket("localhost", 8338)) {
try (SSLSocket socket = (SSLSocket) factory.createSocket("localhost", Integer.parseInt(System.getProperty("httpPort3b")))) {
assertNotNull(socket.getOutputStream());
assertNotNull(socket.getSSLParameters());
assertEquals("TLSv1.3", socket.getSSLParameters().getProtocols()[0]);
Expand All @@ -123,12 +123,12 @@ void testHttpsPort2() throws Exception {
void testDefaultExtensionClass() throws Exception {
PlatformPiranha piranha = new PlatformPiranhaBuilder()
.extensionClass(PlatformExtension.class.getName())
.httpPort(8080)
.httpPort(Integer.parseInt(System.getProperty("httpPort4")))
.verbose(true)
.build();
piranha.start();
Thread.sleep(5000);
try (Socket socket = new Socket("localhost", 8080)) {
try (Socket socket = new Socket("localhost", Integer.parseInt(System.getProperty("httpPort4")))) {
assertNotNull(socket.getOutputStream());
} catch (ConnectException e) {
}
Expand Down
146 changes: 146 additions & 0 deletions multi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>cloud.piranha</groupId>
<artifactId>project</artifactId>
<version>24.8.0-SNAPSHOT</version>
</parent>

<groupId>cloud.piranha</groupId>
<artifactId>piranha-multi</artifactId>
<packaging>jar</packaging>

<name>Piranha - Multi</name>

<dependencies>
<!-- compile -->
<dependency>
<groupId>cloud.piranha.feature</groupId>
<artifactId>piranha-feature-exitonstop</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cloud.piranha.feature</groupId>
<artifactId>piranha-feature-http</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cloud.piranha.feature</groupId>
<artifactId>piranha-feature-https</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cloud.piranha.feature</groupId>
<artifactId>piranha-feature-logging</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cloud.piranha.feature</groupId>
<artifactId>piranha-feature-webapps</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>piranha-multi</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>validate</phase>
<configuration>
<portNames>
<portName>httpPort</portName>
<portName>httpPort2</portName>
<portName>httpsPort2</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>cloud.piranha.multi.MultiPiranhaMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<httpPort>${httpPort}</httpPort>
<httpPort2>${httpPort2}</httpPort2>
<httpsPort2>${httpsPort2}</httpsPort2>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
35 changes: 35 additions & 0 deletions multi/src/main/assembly/zip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<baseDirectory>piranha</baseDirectory>
<formats>
<format>zip</format>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/zip</directory>
<outputDirectory></outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}/webapps</directory>
<outputDirectory>webapps</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/piranha-multi.jar</source>
<outputDirectory>lib</outputDirectory>
</file>
</files>
<dependencySets>
<dependencySet>
<excludes>
<exclude>${project.groupId}:${project.artifactId}:jar:*</exclude>
</excludes>
<outputDirectory>lib</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
</dependencySet>
</dependencySets>
</assembly>
7 changes: 7 additions & 0 deletions multi/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM eclipse-temurin:21
RUN useradd -m piranha
ADD target/piranha-multi.tar.gz /home/piranha/
RUN chown -R piranha:piranha /home/piranha
WORKDIR /home/piranha/piranha/bin
USER piranha
CMD ["/bin/bash", "./run.sh"]
Loading

0 comments on commit d334ba7

Please sign in to comment.