Add run-on-start configuration to control initial update execution
Build and Push Docker Image / build-and-push (push) Successful in 56s
Build and Push Docker Image / build-and-push (push) Successful in 56s
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
public class JvsConfig {
|
public class JvsConfig {
|
||||||
private String configPath;
|
private String configPath;
|
||||||
private String baseDir;
|
private String baseDir;
|
||||||
|
private boolean runOnStart;
|
||||||
private List<RepoConfig> repositories;
|
private List<RepoConfig> repositories;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package codes.thischwa.jvs.service;
|
package codes.thischwa.jvs.service;
|
||||||
|
|
||||||
|
import codes.thischwa.jvs.config.JvsConfig;
|
||||||
import codes.thischwa.jvs.model.GitRepository;
|
import codes.thischwa.jvs.model.GitRepository;
|
||||||
import codes.thischwa.jvs.repository.GitRepositoryRepository;
|
import codes.thischwa.jvs.repository.GitRepositoryRepository;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -8,6 +9,8 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -18,7 +21,15 @@ public class UpdateScheduler {
|
|||||||
private final GitRepositoryRepository repository;
|
private final GitRepositoryRepository repository;
|
||||||
private final GitService gitService;
|
private final GitService gitService;
|
||||||
private final JavadocService javadocService;
|
private final JavadocService javadocService;
|
||||||
|
private final JvsConfig jvsConfig;
|
||||||
|
|
||||||
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
|
public void onApplicationReady() {
|
||||||
|
if (jvsConfig.isRunOnStart()) {
|
||||||
|
log.info("'jvs.run-on-start' is enabled – running initial update.");
|
||||||
|
updateAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "${jvs.cron}")
|
@Scheduled(cron = "${jvs.cron}")
|
||||||
public void updateAll() {
|
public void updateAll() {
|
||||||
|
|||||||
@@ -13,3 +13,4 @@ jvs:
|
|||||||
config-path: ./jvs.yml
|
config-path: ./jvs.yml
|
||||||
base-dir: ./javadoc-storage
|
base-dir: ./javadoc-storage
|
||||||
cron: 0 0/15 * * * ?
|
cron: 0 0/15 * * * ?
|
||||||
|
run-on-start: false
|
||||||
|
|||||||
Reference in New Issue
Block a user