Skip to content

Commit 6aa19fe

Browse files
committed
task pool size from properties
1 parent 08929a3 commit 6aa19fe

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

core/src/main/java/com/flowci/core/common/config/AppConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.core.ResolvableType;
3535
import org.springframework.core.task.TaskExecutor;
3636
import org.springframework.scheduling.annotation.EnableScheduling;
37+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
3738

3839
import javax.annotation.PostConstruct;
3940
import java.io.IOException;
@@ -80,8 +81,10 @@ public ObjectMapper objectMapper() {
8081
}
8182

8283
@Bean("appTaskExecutor")
83-
public TaskExecutor getAppTaskExecutor() {
84-
return ThreadHelper.createTaskExecutor(100, 100, 50, "app-task-");
84+
public ThreadPoolTaskExecutor getAppTaskExecutor() {
85+
int corePoolSize = appProperties.getCorePoolSize();
86+
int maxPoolSize = appProperties.getMaxPoolSize();
87+
return ThreadHelper.createTaskExecutor(maxPoolSize, corePoolSize, 10, "app-task-");
8588
}
8689

8790
@Bean(name = "applicationEventMulticaster")

core/src/main/java/com/flowci/core/common/config/AppProperties.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class AppProperties {
5757

5858
private boolean socketContainer;
5959

60+
private int corePoolSize;
61+
62+
private int maxPoolSize;
63+
6064
@Bean("zkProperties")
6165
@ConfigurationProperties(prefix = "app.zookeeper")
6266
public Zookeeper zk() {

core/src/main/resources/flow.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ app.secret=${FLOWCI_SECRET:qazWSXedcRFV12#$}
55
app.auto-local-agent-host=${FLOWCI_AUTO_AGENT:true}
66
app.default-smtp-config=true
77
app.socket-container=true
8+
app.core-pool-size=100
9+
app.max-pool-size=200
810

911
app.auth.enabled=true
1012
app.auth.expire-seconds=7200

core/src/test/resources/flow.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ app.secret=qazWSXedcRFV12#$
55
app.auto-local-agent-host=false
66
app.default-smtp-config=false
77
app.socket-container=false
8+
app.core-pool-size=100
9+
app.max-pool-size=200
810

911
app.auth.enabled=false
1012
app.auth.expire-seconds=5

0 commit comments

Comments
 (0)