-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use Spring Fu project to improve the startup time and make the Spring Boot configuration more explicit * remove the ResourceLoader * Add -noverify * Update to Spring Boot 2.1.0.RC1
- Loading branch information
Showing
33 changed files
with
460 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
FROM openjdk:8-jdk AS workspace | ||
|
||
COPY . /root/project | ||
|
||
WORKDIR /root/project | ||
COPY gradle gradle/ | ||
COPY gradlew ./ | ||
RUN ./gradlew --no-daemon --version | ||
|
||
ENV TERM=dumb | ||
|
||
COPY build.gradle ./ | ||
RUN ./gradlew --info --no-daemon --console=plain downloadDependencies | ||
|
||
RUN ./gradlew --no-daemon build -x check | ||
COPY . . | ||
|
||
FROM openjdk:8-jre | ||
RUN ./gradlew --no-daemon --info --console=plain build -x check | ||
|
||
FROM openjdk:11-jre | ||
|
||
WORKDIR /app | ||
|
||
RUN java -Xshare:dump | ||
|
||
COPY --from=workspace /root/project/app/build/libs/app.jar app.jar | ||
COPY --from=workspace /root/project/plugins/*/build/libs/*.jar plugins/ | ||
|
||
ENV JAVA_OPTS="" | ||
ENV JAVA_MEMORY_OPTS="-XX:+ExitOnOutOfMemoryError -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseG1GC -XshowSettings:vm" | ||
ENV JAVA_MEMORY_OPTS="-XX:+ExitOnOutOfMemoryError -XshowSettings:vm -noverify" | ||
|
||
CMD ["sh", "-c", "java $JAVA_MEMORY_OPTS $JAVA_OPTS -jar app.jar"] | ||
CMD ["sh", "-c", "java -Xshare:on $JAVA_MEMORY_OPTS $JAVA_OPTS -jar app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
api/src/main/java/com/github/bsideup/liiklus/config/ExporterProfile.java
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
api/src/main/java/com/github/bsideup/liiklus/config/GatewayProfile.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
api/src/main/java/com/github/bsideup/liiklus/config/LiiklusConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 60 additions & 13 deletions
73
app/src/main/java/com/github/bsideup/liiklus/config/GRPCConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,73 @@ | ||
package com.github.bsideup.liiklus.config; | ||
|
||
import com.github.bsideup.liiklus.service.ReactorLiiklusServiceImpl; | ||
import io.grpc.Server; | ||
import io.grpc.ServerBuilder; | ||
import io.grpc.inprocess.InProcessServerBuilder; | ||
import io.grpc.netty.NettyServerBuilder; | ||
import io.netty.channel.nio.NioEventLoopGroup; | ||
import org.lognet.springboot.grpc.GRpcServerBuilderConfigurer; | ||
import org.springframework.context.annotation.Configuration; | ||
import lombok.Data; | ||
import lombok.val; | ||
import org.springframework.boot.context.properties.bind.Binder; | ||
import org.springframework.context.ApplicationContextInitializer; | ||
import org.springframework.context.support.GenericApplicationContext; | ||
import org.springframework.core.env.Profiles; | ||
import reactor.core.scheduler.Schedulers; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
@Configuration | ||
@GatewayProfile | ||
public class GRPCConfiguration extends GRpcServerBuilderConfigurer { | ||
public class GRPCConfiguration implements ApplicationContextInitializer<GenericApplicationContext> { | ||
|
||
@Override | ||
public void configure(ServerBuilder<?> serverBuilder) { | ||
serverBuilder.directExecutor(); | ||
|
||
if (serverBuilder instanceof NettyServerBuilder) { | ||
((NettyServerBuilder) serverBuilder) | ||
.workerEventLoopGroup(new NioEventLoopGroup(Schedulers.DEFAULT_POOL_SIZE)) | ||
.permitKeepAliveTime(150, TimeUnit.SECONDS) | ||
.permitKeepAliveWithoutCalls(true); | ||
public void initialize(GenericApplicationContext applicationContext) { | ||
val environment = applicationContext.getEnvironment(); | ||
|
||
if (!environment.acceptsProfiles(Profiles.of("gateway"))) { | ||
return; | ||
} | ||
|
||
val binder = Binder.get(environment); | ||
|
||
val serverProperties = binder.bind("grpc", GRpcServerProperties.class).orElseGet(GRpcServerProperties::new); | ||
|
||
applicationContext.registerBean(ReactorLiiklusServiceImpl.class); | ||
|
||
applicationContext.registerBean( | ||
Server.class, | ||
() -> { | ||
ServerBuilder<?> serverBuilder; | ||
|
||
if (serverProperties.isEnabled()) { | ||
serverBuilder = NettyServerBuilder | ||
.forPort(serverProperties.getPort()) | ||
.workerEventLoopGroup(new NioEventLoopGroup(Schedulers.DEFAULT_POOL_SIZE)) | ||
.permitKeepAliveTime(150, TimeUnit.SECONDS) | ||
.permitKeepAliveWithoutCalls(true); | ||
} else { | ||
serverBuilder = InProcessServerBuilder.forName(serverProperties.getInProcessServerName()); | ||
} | ||
|
||
return serverBuilder | ||
.directExecutor() | ||
.addService(applicationContext.getBean(ReactorLiiklusServiceImpl.class)) | ||
.build(); | ||
}, | ||
it -> { | ||
it.setInitMethodName("start"); | ||
it.setDestroyMethodName("shutdownNow"); | ||
} | ||
); | ||
} | ||
|
||
@Data | ||
static class GRpcServerProperties { | ||
|
||
int port = 6565; | ||
|
||
boolean enabled = true; | ||
|
||
String inProcessServerName; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.