-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from FlowCI/develop
Develop
- Loading branch information
Showing
174 changed files
with
5,981 additions
and
1,684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,10 @@ domain.api = http://localhost:8080 | |
domain.web = http://localhost:3000 | ||
domain.cc = http://localhost:8080 | ||
|
||
system.email = [email protected] | ||
system.username = admin | ||
system.password = 123456 | ||
|
||
task.job.toggle.execution_timeout = false | ||
## 6s expire job | ||
task.job.toggle.execution_create_session_duration = 600 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,24 +34,27 @@ | |
import org.apache.velocity.app.VelocityEngine; | ||
import org.apache.velocity.runtime.RuntimeConstants; | ||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.event.ApplicationEventMulticaster; | ||
import org.springframework.context.event.SimpleApplicationEventMulticaster; | ||
import org.springframework.scheduling.TaskScheduler; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
/** | ||
* @author yang | ||
*/ | ||
@Configuration | ||
@Import({CachingConfig.class, DatabaseConfig.class}) | ||
@Import({SchedulerConfig.class, CachingConfig.class, DatabaseConfig.class}) | ||
public class AppConfig extends AppConfigBase { | ||
|
||
public final static String NAME = "API"; | ||
|
||
public final static String VERSION = "0.1.0"; | ||
public final static String VERSION = "v0.1-alpha"; | ||
|
||
public final static String DEFAULT_YML_FILE = ".flow.yml"; | ||
|
||
|
@@ -67,11 +70,6 @@ public class AppConfig extends AppConfigBase { | |
|
||
private final static int MULTICASTER_ASYNC_POOL_SIZE = 1; | ||
|
||
public final static String DEFAULT_USER_EMAIL = "[email protected]"; | ||
public final static String DEFAULT_USER_NAME = "admin"; | ||
|
||
public final static String DEFAULT_USER_PASSWORD = "123456"; | ||
|
||
private final static ThreadPoolTaskExecutor executor = | ||
ThreadUtil.createTaskExecutor(ASYNC_POOL_SIZE, ASYNC_POOL_SIZE / 10, 100, THREAD_NAME_PREFIX); | ||
|
||
|
@@ -85,6 +83,20 @@ public class AppConfig extends AppConfigBase { | |
@Value("${domain.cc}") | ||
private String ccDomain; | ||
|
||
@Value(value = "${system.email}") | ||
private String email; | ||
|
||
@Value(value = "${system.username}") | ||
private String username; | ||
|
||
@Value(value = "${system.password}") | ||
private String password; | ||
|
||
@Bean | ||
public User superUser() { | ||
return new User(email, username, password); | ||
} | ||
|
||
@Bean | ||
public Path workspace() { | ||
try { | ||
|
@@ -125,7 +137,7 @@ public ThreadPoolTaskExecutor taskExecutor() { | |
*/ | ||
@Bean | ||
public PlatformQueue<CmdCallbackQueueItem> cmdCallbackQueue() { | ||
return new InMemoryQueue<>(executor, 50); | ||
return new InMemoryQueue<>(executor, 50, "CmdCallbackQueue"); | ||
} | ||
|
||
@Override | ||
|
83 changes: 83 additions & 0 deletions
83
platform-api/src/main/java/com/flow/platform/api/config/SchedulerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2017 flow.ci | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.flow.platform.api.config; | ||
|
||
import com.flow.platform.api.task.NodeCrontabTask; | ||
import com.flow.platform.core.exception.IllegalStatusException; | ||
import java.io.IOException; | ||
import org.quartz.JobBuilder; | ||
import org.quartz.JobDetail; | ||
import org.quartz.Scheduler; | ||
import org.quartz.SchedulerException; | ||
import org.quartz.impl.StdSchedulerFactory; | ||
import org.springframework.beans.factory.annotation.Configurable; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.SchedulingConfigurer; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | ||
import org.springframework.scheduling.config.ScheduledTaskRegistrar; | ||
|
||
/** | ||
* @author yang | ||
*/ | ||
@Configurable | ||
@EnableScheduling | ||
public class SchedulerConfig implements SchedulingConfigurer { | ||
|
||
private final static int DEFAULT_SCHEDULER_POOL_SIZE = 10; | ||
|
||
/** | ||
* Thread pool for spring scheduling | ||
*/ | ||
@Bean(destroyMethod = "shutdown") | ||
public ThreadPoolTaskScheduler schedulerTaskExecutor() { | ||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); | ||
scheduler.setPoolSize(DEFAULT_SCHEDULER_POOL_SIZE); | ||
scheduler.setDaemon(true); | ||
scheduler.setThreadNamePrefix("api-task-"); | ||
scheduler.initialize(); | ||
return scheduler; | ||
} | ||
|
||
/** | ||
* Setup quartz scheduler | ||
*/ | ||
@Bean | ||
public Scheduler quartzScheduler() { | ||
try { | ||
StdSchedulerFactory factory = new StdSchedulerFactory(); | ||
factory.initialize(new ClassPathResource("quartz.properties").getInputStream()); | ||
return factory.getScheduler(); | ||
} catch (SchedulerException | IOException e) { | ||
throw new IllegalStatusException("Unable to init quartz: " + e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Setup flow crontab job detail | ||
*/ | ||
@Bean | ||
public JobDetail nodeCrontabDetail() { | ||
return JobBuilder.newJob(NodeCrontabTask.class).storeDurably(true).build(); | ||
} | ||
|
||
@Override | ||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { | ||
taskRegistrar.setTaskScheduler(schedulerTaskExecutor()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.