Skip to content

Commit

Permalink
move config item to softwarelab on application.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstar-baba committed Sep 28, 2020
1 parent d2e08c1 commit 5d851bc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

@Component
@Slf4j
@ConditionalOnProperty(prefix = "checker", value = "enabled", havingValue = "true")
@ConditionalOnProperty(prefix = "softwarelab.checker", value = "enabled", havingValue = "true")
public class ContainerChecker {

@Value("${checker.sleepMillSeconds:500}")
@Value("${softwarelab.checker.sleepMillSeconds:500}")
private int sleepMillSeconds;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class HardwareChecker {

private final SystemInfo systemInfo = new SystemInfo();

private Object lock = new Object();

public HardwareInfo getLast() {
return hardwareInfos.getLast();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
Expand All @@ -32,13 +33,14 @@
*/
@Component
@Slf4j
@ConditionalOnProperty(prefix = "softwarelab.checker", value = "enabled", havingValue = "true")
public class ImageChecker {

private Map<AppVersion, WebSocketSessionAndCallback> pullImageMap = new ConcurrentHashMap<>();

private ObjectMapper objectMapper = new ObjectMapper();

@Value("${checker.sleepMillSeconds:500}")
@Value("${softwarelab.checker.sleepMillSeconds:500}")
private int sleepMillSeconds;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class InstanceController extends BaseController {

private ObjectMapper objectMapper = new ObjectMapper();

@Value("${instance.maxSize}")
@Value("${softwarelab.instance.maxSize}")
private Integer maxSize;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UserController extends BaseController {
@Autowired
private ISysUserService userService;

@Value("user.admin.id")
@Value("softwarelab.user.admin.id")
private String adminId;

@RequestMapping(method = RequestMethod.GET, value = "/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
Expand Down Expand Up @@ -50,6 +51,9 @@ public class InstanceServiceImpl extends ServiceImpl<InstanceMapper, Instance> i
@Autowired
private IPortService portService;

@Value("softwarelab.host")
private String host;


private ObjectMapper objectMapper = new ObjectMapper();

Expand Down Expand Up @@ -97,7 +101,7 @@ private void processUrl(ContainerInfo startContainerInfo) {
ports.forEach(containerPortSetting -> {
if(containerPortSetting.getType().equals("http")&& containerPortSetting.isEntrance()){
String url = startContainerInfo.getUrl() != null ? startContainerInfo.getUrl() : "";
startContainerInfo.setUrl("https://localhost:"+containerPortSetting.getTargetPort()+url);
startContainerInfo.setUrl("https://"+host+":"+containerPortSetting.getTargetPort()+url);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class PortServiceImpl implements IPortService {


@Value("${instance.ports}")
@Value("${softwarelab.instance.ports}")
private String ports;

@Autowired
Expand Down
22 changes: 13 additions & 9 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ security:
tokenIssuer: "${JWT_TOKEN_ISSUER:software-lab}"
tokenSigningKey: "${JWT_TOKEN_SIGNING_KEY:codeisbeatiful}"

user:
admin:
id: 00000000-0000-0000-0000-000000000000
softwarelab:
host: localhost
user:
admin:
id: 00000000-0000-0000-0000-000000000000
instance:
ports: 30001-39999
maxSize: 5
checker:
enabled: true
sleepMillSeconds: 500


instance:
ports: 30001-39999
maxSize: 5
source:
path:


checker:
enabled: true
sleepMillSeconds: 500

0 comments on commit 5d851bc

Please sign in to comment.