From 73cd239a7730c3d60bd1e462abb2c88be891c329 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 15 Nov 2019 15:46:34 +0800 Subject: [PATCH] upgrade to Spring Boot 2.2.1 add default periodic scan to prod profile --- README.md | 2 +- komga/build.gradle.kts | 7 ++----- .../main/kotlin/org/gotson/komga/Application.kt | 5 ----- .../komga/domain/persistence/SeriesRepository.kt | 2 +- .../httptrace/HttpTraceConfiguration.kt | 14 ++++++++++++++ .../komga/interfaces/web/opds/OpdsController.kt | 4 ++-- .../komga/interfaces/web/rest/SeriesController.kt | 4 ++-- komga/src/main/resources/application-dev.yml | 5 +++-- komga/src/main/resources/application-docker.yml | 2 +- komga/src/main/resources/application-prod.yml | 7 +++++-- 10 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 komga/src/main/kotlin/org/gotson/komga/infrastructure/httptrace/HttpTraceConfiguration.kt diff --git a/README.md b/README.md index 3e4b9f798..a07780e10 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,12 @@ In order to make Komga run, you need to specify some mandatory configuration key - `SPRING_PROFILES_ACTIVE` / `spring.profiles.active`: `prod` - this will enable the database management and upgrades for new versions. - `SPRING_DATASOURCE_URL` / `spring.datasource.url`: the path of the database file. For Docker I use `jdbc:h2:/config/database.h2`, where `/config/database.h2` is the actual file inside the docker container. You can customize this part if running without docker. -- `KOMGA_LIBRARIES_SCAN_CRON` / `komga.libraries-scan-cron`: a [Spring cron expression](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html) for libraries periodic rescans. `0 0 * * * ?` will rescan every hour. `0 */15 * * * ?` will rescan every 15 minutes. ### Optional configuration You can also use some optional configuration keys: +- `KOMGA_LIBRARIES_SCAN_CRON` / `komga.libraries-scan-cron`: a [Spring cron expression](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html) for libraries periodic rescans. `0 0 * * * ?` will rescan every hour. `0 */15 * * * ?` will rescan every 15 minutes. Defaults to `0 */15 * * * ?` in `prod` profile. - `KOMGA_THREADS_PARSE` / `komga.threads.parse`: the number of worker threads used for book parsing. Defaults to `2`. You can experiment to get better performance. - `KOMGA_LIBRARIES_SCAN_DIRECTORY_EXCLUSIONS` / `komga.libraries-scan-directory-exclusions`: a list of patterns to exclude directories from the scan. If the full path contains any of the patterns, the directory will be ignored. If using the environment variable form use a comma-separated list. diff --git a/komga/build.gradle.kts b/komga/build.gradle.kts index 4344ebfae..f7624f756 100644 --- a/komga/build.gradle.kts +++ b/komga/build.gradle.kts @@ -11,9 +11,9 @@ plugins { kotlin("plugin.jpa") version kotlinVersion kotlin("kapt") version kotlinVersion } - id("org.springframework.boot") version "2.1.9.RELEASE" + id("org.springframework.boot") version "2.2.1.RELEASE" id("io.spring.dependency-management") version "1.0.8.RELEASE" - id("com.github.ben-manes.versions") version "0.25.0" + id("com.github.ben-manes.versions") version "0.27.0" id("com.palantir.docker") version "0.22.1" id("com.github.breadmoirai.github-release") version "2.2.9" id("com.gorylenko.gradle-git-properties") version "2.2.0" @@ -81,12 +81,9 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation("org.springframework.boot:spring-boot-starter-test") { - exclude(module = "junit") exclude(module = "mockito-core") } testImplementation("org.springframework.security:spring-security-test") - testImplementation("org.junit.jupiter:junit-jupiter-engine") - testImplementation("org.junit.jupiter:junit-jupiter-params") testImplementation("com.ninja-squad:springmockk:1.1.3") testImplementation("io.mockk:mockk:1.9.3") testImplementation("com.google.jimfs:jimfs:1.1") diff --git a/komga/src/main/kotlin/org/gotson/komga/Application.kt b/komga/src/main/kotlin/org/gotson/komga/Application.kt index c22fcc716..71881348f 100644 --- a/komga/src/main/kotlin/org/gotson/komga/Application.kt +++ b/komga/src/main/kotlin/org/gotson/komga/Application.kt @@ -1,16 +1,11 @@ package org.gotson.komga -import org.gotson.komga.infrastructure.configuration.KomgaProperties import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.runApplication import org.springframework.data.jpa.repository.config.EnableJpaAuditing import org.springframework.scheduling.annotation.EnableScheduling @SpringBootApplication -@EnableConfigurationProperties( - KomgaProperties::class -) @EnableScheduling @EnableJpaAuditing class Application diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt index 25f0fe7c0..084799fea 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt @@ -15,7 +15,7 @@ interface SeriesRepository : JpaRepository, JpaSpecificationExecut fun findByLibraryIn(libraries: Collection, sort: Sort): List fun findByLibraryIn(libraries: Collection, page: Pageable): Page fun findByLibraryId(libraryId: Long, sort: Sort): List - fun findByLibraryIdAndUrlNotIn(libraryId: Long, urls: Iterable): List + fun findByLibraryIdAndUrlNotIn(libraryId: Long, urls: Collection): List fun findByLibraryIdAndUrl(libraryId: Long, url: URL): Series? fun deleteByLibraryId(libraryId: Long) } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/httptrace/HttpTraceConfiguration.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/httptrace/HttpTraceConfiguration.kt new file mode 100644 index 000000000..b15466e98 --- /dev/null +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/httptrace/HttpTraceConfiguration.kt @@ -0,0 +1,14 @@ +package org.gotson.komga.infrastructure.httptrace + +import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class HttpTraceConfiguration { + + private val httpTraceRepository = InMemoryHttpTraceRepository() + + @Bean + fun httpTraceRepository() = httpTraceRepository +} diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/web/opds/OpdsController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/web/opds/OpdsController.kt index df26eae9c..343043324 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/web/opds/OpdsController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/web/opds/OpdsController.kt @@ -125,7 +125,7 @@ class OpdsController( } if (specs.isNotEmpty()) { - seriesRepository.findAll(specs.reduce { acc, spec -> acc.and(spec) }, sort) + seriesRepository.findAll(specs.reduce { acc, spec -> acc.and(spec)!! }, sort) } else { seriesRepository.findAll(sort) } @@ -148,7 +148,7 @@ class OpdsController( fun getLatestSeries( @AuthenticationPrincipal principal: KomgaPrincipal ): OpdsFeed { - val sort = Sort(Sort.Direction.DESC, "lastModifiedDate") + val sort = Sort.by(Sort.Direction.DESC, "lastModifiedDate") val series = if (principal.user.sharedAllLibraries) { seriesRepository.findAll(sort) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/SeriesController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/SeriesController.kt index c26640cca..e6ba4745c 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/SeriesController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/web/rest/SeriesController.kt @@ -79,7 +79,7 @@ class SeriesController( } if (specs.isNotEmpty()) { - seriesRepository.findAll(specs.reduce { acc, spec -> acc.and(spec) }, pageRequest) + seriesRepository.findAll(specs.reduce { acc, spec -> acc.and(spec)!! }, pageRequest) } else { seriesRepository.findAll(pageRequest) } @@ -94,7 +94,7 @@ class SeriesController( val pageRequest = PageRequest.of( page.pageNumber, page.pageSize, - Sort(Sort.Direction.DESC, "lastModifiedDate") + Sort.by(Sort.Direction.DESC, "lastModifiedDate") ) return if (principal.user.sharedAllLibraries) { diff --git a/komga/src/main/resources/application-dev.yml b/komga/src/main/resources/application-dev.yml index 9383d3707..e3aa090d4 100644 --- a/komga/src/main/resources/application-dev.yml +++ b/komga/src/main/resources/application-dev.yml @@ -11,8 +11,9 @@ komga: spring: profiles: include: flyway -logging.file: komga-dev.log logging: - file.max-history: 1 + file: + max-history: 1 + name: komga-dev.log level: org.gotson.komga: debug diff --git a/komga/src/main/resources/application-docker.yml b/komga/src/main/resources/application-docker.yml index 28716f19f..a67d562f2 100644 --- a/komga/src/main/resources/application-docker.yml +++ b/komga/src/main/resources/application-docker.yml @@ -3,6 +3,6 @@ spring: include: flyway datasource: url: jdbc:h2:/config/database.h2 -logging.file: /config/logs/komga.log +logging.file.name: /config/logs/komga.log komga: libraries-scan-cron: "0 */15 * * * ?" diff --git a/komga/src/main/resources/application-prod.yml b/komga/src/main/resources/application-prod.yml index 949c75613..39cd656b7 100644 --- a/komga/src/main/resources/application-prod.yml +++ b/komga/src/main/resources/application-prod.yml @@ -1,6 +1,9 @@ spring: profiles: include: flyway -logging.file: komga.log logging: - file.max-history: 10 + file: + max-history: 10 + name: komga.log +komga: + libraries-scan-cron: "0 */15 * * * ?"