Skip to content

Commit

Permalink
Replace ApplicationRunner with EventListener to fix startup time (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums authored Sep 13, 2024
1 parent aa7b783 commit 2f28091
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package de.tum.in.www1.hephaestus.codereview.base;

import de.tum.in.www1.hephaestus.codereview.user.User;
import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MappedSuperclass;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class GitHubDataSyncScheduler implements ApplicationRunner {
public class GitHubDataSyncScheduler {

private static final Logger logger = LoggerFactory.getLogger(GitHubDataSyncScheduler.class);
private final GitHubDataSyncService dataSyncService;
Expand All @@ -21,8 +21,8 @@ public GitHubDataSyncScheduler(GitHubDataSyncService dataSyncService) {
this.dataSyncService = dataSyncService;
}

@Override
public void run(ApplicationArguments args) throws Exception {
@EventListener(ApplicationReadyEvent.class)
public void run() {
if (runOnStartup) {
logger.info("Starting initial GitHub data sync...");
dataSyncService.syncData();
Expand Down

0 comments on commit 2f28091

Please sign in to comment.