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 {
|
||||
private String configPath;
|
||||
private String baseDir;
|
||||
private boolean runOnStart;
|
||||
private List<RepoConfig> repositories;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package codes.thischwa.jvs.service;
|
||||
|
||||
import codes.thischwa.jvs.config.JvsConfig;
|
||||
import codes.thischwa.jvs.model.GitRepository;
|
||||
import codes.thischwa.jvs.repository.GitRepositoryRepository;
|
||||
import java.io.File;
|
||||
@@ -8,6 +9,8 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.stereotype.Service;
|
||||
|
||||
@@ -18,7 +21,15 @@ public class UpdateScheduler {
|
||||
private final GitRepositoryRepository repository;
|
||||
private final GitService gitService;
|
||||
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}")
|
||||
public void updateAll() {
|
||||
|
||||
@@ -13,3 +13,4 @@ jvs:
|
||||
config-path: ./jvs.yml
|
||||
base-dir: ./javadoc-storage
|
||||
cron: 0 0/15 * * * ?
|
||||
run-on-start: false
|
||||
|
||||
Reference in New Issue
Block a user