Skip to content

The Unified and Autonomous Development Platform

Add more environment variables to control Hikari db connection pool

Robin Shened61f23b46fb
diff --git a/server-product/src/main/java/io/onedev/server/product/ProductModule.java b/server-product/src/main/java/io/onedev/server/product/ProductModule.java
index e19870f388..813368d158 100644
--- a/server-product/src/main/java/io/onedev/server/product/ProductModule.java
+++ b/server-product/src/main/java/io/onedev/server/product/ProductModule.java
@@ -19,6 +19,13 @@ import io.onedev.server.util.jetty.ServletConfigurator;
public class ProductModule extends AbstractPluginModule {
+ private static final String[] HIBERNATE_PROPS = new String[] {
+ DIALECT, DRIVER, URL, USER, PASS, "hibernate.hikari.leakDetectionThreshold",
+ "hibernate.hikari.maxLifetime", "hibernate.hikari.connectionTimeout",
+ "hibernate.hikari.maximumPoolSize", "hibernate.hikari.validationTimeout",
+ "hibernate.show_sql"
+ };
+
@Override
protected void configure() {
super.configure();
@@ -29,20 +36,11 @@ public class ProductModule extends AbstractPluginModule {
hibernateProps.setProperty(URL,
StringUtils.replace(url, "${installDir}", Bootstrap.installDir.getAbsolutePath()));
- if (System.getenv(DIALECT.replace('.', '_')) != null)
- hibernateProps.setProperty(DIALECT, System.getenv(DIALECT.replace('.', '_')));
- if (System.getenv(DRIVER.replace('.', '_')) != null)
- hibernateProps.setProperty(DRIVER, System.getenv(DRIVER.replace('.', '_')));
- if (System.getenv(URL.replace('.', '_')) != null)
- hibernateProps.setProperty(URL, System.getenv(URL.replace('.', '_')));
- if (System.getenv(USER.replace('.', '_')) != null)
- hibernateProps.setProperty(USER, System.getenv(USER.replace('.', '_')));
- if (System.getenv(PASS.replace('.', '_')) != null)
- hibernateProps.setProperty(PASS, System.getenv(PASS.replace('.', '_')));
-
- String maxPoolSizeProp = "hibernate.hikari.maximumPoolSize";
- if (System.getenv(maxPoolSizeProp.replace('.', '_')) != null)
- hibernateProps.setProperty(maxPoolSizeProp, System.getenv(maxPoolSizeProp.replace('.', '_')));
+ for (String prop: HIBERNATE_PROPS) {
+ String env = System.getenv(prop.replace('.', '_'));
+ if (env != null)
+ hibernateProps.setProperty(prop, env);
+ }
bind(HibernateProperties.class).toInstance(hibernateProps);