Skip to content

Commit

Permalink
Allow to specify a pool size (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Kirch committed Oct 9, 2023
1 parent 0351f94 commit f9b5a52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ To build external URL, the server is expecting a `DOCS_BASE_URL` environment var
- `DATABASE_URL`: The jdbc connection string to be used by `hibernate`.
- `DATABASE_USER`: The user which should be used for the database connection.
- `DATABASE_PASSWORD`: The password to be used for the database connection.
- `DATABASE_POOL_SIZE`: The pool size to be used for the database connection.

- Language
- `DOCS_DEFAULT_LANGUAGE`: The language which will be used as default. Currently supported values are:
Expand Down Expand Up @@ -122,6 +123,7 @@ services:
DATABASE_URL: "jdbc:postgresql://teedy-db:5432/teedy"
DATABASE_USER: "teedy_db_user"
DATABASE_PASSWORD: "teedy_db_password"
DATABASE_POOL_SIZE: "10"
volumes:
- ./docs/data:/data
networks:
Expand Down
6 changes: 5 additions & 1 deletion docs-core/src/main/java/com/sismics/util/jpa/EMF.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ private static Properties getEntityManagerProperties() {
String databaseUrl = System.getenv("DATABASE_URL");
String databaseUsername = System.getenv("DATABASE_USER");
String databasePassword = System.getenv("DATABASE_PASSWORD");
String databasePoolSize = System.getenv("DATABASE_POOL_SIZE");
if(databasePoolSize == null) {
databasePoolSize = "10";
}

log.info("Configuring EntityManager from environment parameters");
Properties props = new Properties();
Expand All @@ -103,7 +107,7 @@ private static Properties getEntityManagerProperties() {
props.put("hibernate.max_fetch_depth", "5");
props.put("hibernate.cache.use_second_level_cache", "false");
props.put("hibernate.connection.initial_pool_size", "1");
props.put("hibernate.connection.pool_size", "10");
props.put("hibernate.connection.pool_size", databasePoolSize);
props.put("hibernate.connection.pool_validation_interval", "5");
return props;
}
Expand Down

0 comments on commit f9b5a52

Please sign in to comment.