Skip to content

Commit 204f807

Browse files
committed
Improve startup speed
1 parent e7cb30b commit 204f807

2 files changed

Lines changed: 42 additions & 37 deletions

File tree

  • chat2db-server

chat2db-server/chat2db-server-domain/chat2db-server-domain-repository/src/main/java/ai/chat2db/server/domain/repository/Dbutils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,17 @@ private static void initFlyway(DataSource dataSource) {
110110
if (StringUtils.isNotBlank(currentVersion) && configJson != null && StringUtils.equals(currentVersion,
111111
configJson.getLatestStartupSuccessVersion())) {
112112
return;
113+
}else {
114+
Flyway flyway = Flyway.configure()
115+
.dataSource(dataSource)
116+
.locations("classpath:db/migration")
117+
.load();
118+
flyway.migrate();
119+
120+
121+
configJson.setLatestStartupSuccessVersion(currentVersion);
122+
ConfigUtils.setConfig(configJson);
113123
}
114-
Flyway flyway = Flyway.configure()
115-
.dataSource(dataSource)
116-
.locations("classpath:db/migration")
117-
.load();
118-
flyway.migrate();
119124
}
120125

121126
/**
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
package ai.chat2db.server.start.config.config;
2-
3-
import ai.chat2db.server.tools.common.model.ConfigJson;
4-
import ai.chat2db.server.tools.common.util.ConfigUtils;
5-
import lombok.extern.slf4j.Slf4j;
6-
import org.apache.commons.lang3.StringUtils;
7-
import org.springframework.context.ApplicationListener;
8-
import org.springframework.context.event.ContextRefreshedEvent;
9-
import org.springframework.scheduling.annotation.Async;
10-
import org.springframework.stereotype.Component;
11-
12-
/**
13-
* Execute tasks after startup is completed
14-
*
15-
* @author Jiaju Zhuang
16-
*/
17-
@Component
18-
@Slf4j
19-
public class AsyncContextRefreshedListener implements ApplicationListener<ContextRefreshedEvent> {
20-
@Override
21-
@Async
22-
public void onApplicationEvent(ContextRefreshedEvent event) {
23-
// Successfully set up startup
24-
String currentVersion = ConfigUtils.getLocalVersion();
25-
ConfigJson configJson = ConfigUtils.getConfig();
26-
if (StringUtils.isNotBlank(currentVersion) && !StringUtils.equals(currentVersion,
27-
configJson.getLatestStartupSuccessVersion())) {
28-
configJson.setLatestStartupSuccessVersion(currentVersion);
29-
ConfigUtils.setConfig(configJson);
30-
}
31-
}
32-
}
1+
//package ai.chat2db.server.start.config.config;
2+
//
3+
//import ai.chat2db.server.tools.common.model.ConfigJson;
4+
//import ai.chat2db.server.tools.common.util.ConfigUtils;
5+
//import lombok.extern.slf4j.Slf4j;
6+
//import org.apache.commons.lang3.StringUtils;
7+
//import org.springframework.context.ApplicationListener;
8+
//import org.springframework.context.event.ContextRefreshedEvent;
9+
//import org.springframework.scheduling.annotation.Async;
10+
//import org.springframework.stereotype.Component;
11+
//
12+
///**
13+
// * Execute tasks after startup is completed
14+
// *
15+
// * @author Jiaju Zhuang
16+
// */
17+
//@Component
18+
//@Slf4j
19+
//public class AsyncContextRefreshedListener implements ApplicationListener<ContextRefreshedEvent> {
20+
// @Override
21+
// @Async
22+
// public void onApplicationEvent(ContextRefreshedEvent event) {
23+
// // Successfully set up startup
24+
// String currentVersion = ConfigUtils.getLocalVersion();
25+
// ConfigJson configJson = ConfigUtils.getConfig();
26+
// if (StringUtils.isNotBlank(currentVersion) && !StringUtils.equals(currentVersion,
27+
// configJson.getLatestStartupSuccessVersion())) {
28+
// configJson.setLatestStartupSuccessVersion(currentVersion);
29+
// ConfigUtils.setConfig(configJson);
30+
// }
31+
// }
32+
//}

0 commit comments

Comments
 (0)