Commit da253db7 authored by 李丛阳's avatar 李丛阳

apache

parent ad8204f3
...@@ -82,8 +82,12 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -82,8 +82,12 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
result = new CommandResult(ResultCode.FAIL,"容器配置文件有误!",lxc); result = new CommandResult(ResultCode.FAIL,"容器配置文件有误!",lxc);
return result; return result;
} }
/*启动路径*/
String dockerPath = global.getPHYSICAL_UPLOAD_SERVER_LOCATION() + File.separator +
global.getLxcDockerfilePath() + File.separator + lxc.getUserId() + File.separator;
/*2.docker-compose 起容器*/ /*2.docker-compose 起容器*/
result = lxcCommand.startOrDownLxc(destPath); log.info("执行路径:{}",dockerPath);
result = lxcCommand.startOrDownLxc(dockerPath);
if(!result.isSuccess()) { if(!result.isSuccess()) {
result = new CommandResult(ResultCode.FAIL,"容器启动失败!",lxc); result = new CommandResult(ResultCode.FAIL,"容器启动失败!",lxc);
return result; return result;
...@@ -103,7 +107,7 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -103,7 +107,7 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
Map jobParam = new HashMap(); Map jobParam = new HashMap();
jobParam.put("redisKeyId",key); jobParam.put("redisKeyId",key);
jobParam.put("containerName",this.getModelProject(lxc.getCode()) + "_" + lxc.getUserId()); jobParam.put("containerName",this.getModelProject(lxc.getCode()) + "_" + lxc.getUserId());
jobParam.put("containerPath",destPath); jobParam.put("containerPath",dockerPath);
jobParam.put("containerPort",port); jobParam.put("containerPort",port);
JobDetail job = JobBuilder.newJob(StopLxcJob.class). JobDetail job = JobBuilder.newJob(StopLxcJob.class).
withIdentity(global.getLxcPrefix() + lxc.getUserId(), JOB_LXC_GROUP). withIdentity(global.getLxcPrefix() + lxc.getUserId(), JOB_LXC_GROUP).
......
...@@ -34,6 +34,11 @@ public class Global { ...@@ -34,6 +34,11 @@ public class Global {
@Value("${global.path.base_upload_server_location}") @Value("${global.path.base_upload_server_location}")
private String BASE_UPLOAD_SERVER_LOCATION; private String BASE_UPLOAD_SERVER_LOCATION;
/*容器外路径*/
@Value("${global.path.physical_upload_server_location}")
private String PHYSICAL_UPLOAD_SERVER_LOCATION;
/*课程相关文件路径*/ /*课程相关文件路径*/
@Value("${global.path.course_location}") @Value("${global.path.course_location}")
private String COURSE_LOCATION; private String COURSE_LOCATION;
......
...@@ -58,10 +58,12 @@ public class LxcCommand { ...@@ -58,10 +58,12 @@ public class LxcCommand {
CommandResult commandResult = null; CommandResult commandResult = null;
try { try {
File dirPath = new File(dest); File dirPath = new File(dest);
if(!dirPath.exists() || !dirPath.isDirectory()){ if(!isRemote) {
log.error("目录错误 ...." + dest); if (!dirPath.exists() || !dirPath.isDirectory()) {
commandResult = new CommandResult(ResultCode.FAIL,"目录不存在",null); log.error("目录错误 ...." + dest);
return commandResult; commandResult = new CommandResult(ResultCode.FAIL, "目录不存在", null);
return commandResult;
}
} }
if (isStart) if (isStart)
if (isRemote) if (isRemote)
...@@ -73,7 +75,9 @@ public class LxcCommand { ...@@ -73,7 +75,9 @@ public class LxcCommand {
remoteExecuteCommand.execute(DOWN_LXC_COMMAND,dest); remoteExecuteCommand.execute(DOWN_LXC_COMMAND,dest);
else else
Runtime.getRuntime().exec("cd " + dest + " && " + DOWN_LXC_COMMAND); Runtime.getRuntime().exec("cd " + dest + " && " + DOWN_LXC_COMMAND);
dirPath.delete(); if(!isRemote) {
dirPath.delete();
}
} }
commandResult = new CommandResult(ResultCode.SUCCESS,null,null); commandResult = new CommandResult(ResultCode.SUCCESS,null,null);
}catch (Exception e){ }catch (Exception e){
......
...@@ -105,6 +105,7 @@ global: ...@@ -105,6 +105,7 @@ global:
max_password: 16 max_password: 16
path: path:
base_upload_server_location: /working/resource/eduServer/ base_upload_server_location: /working/resource/eduServer/
physical_upload_server_location: /working/resource/eduServer
course_location: course course_location: course
lesson_location: lesson lesson_location: lesson
sl_location: sl sl_location: sl
......
...@@ -55,7 +55,7 @@ spring: ...@@ -55,7 +55,7 @@ spring:
add-mappings: false add-mappings: false
redis: redis:
host: 106.2.3.134 host: 106.2.3.134
port: 7481 port: 7482
pool: pool:
max-idle: 50 max-idle: 50
max-active: 1000 max-active: 1000
...@@ -105,6 +105,7 @@ global: ...@@ -105,6 +105,7 @@ global:
max_password: 16 max_password: 16
path: path:
base_upload_server_location: /working/resource/eduServer/ base_upload_server_location: /working/resource/eduServer/
physical_upload_server_location: /working/dockervolume/edu2_data_ubuntu/eduServer
course_location: course course_location: course
lesson_location: lesson lesson_location: lesson
sl_location: sl sl_location: sl
...@@ -141,6 +142,6 @@ global: ...@@ -141,6 +142,6 @@ global:
html_project: '1002' html_project: '1002'
serverLxc: serverLxc:
ip: 192.168.1.130 ip: 106.2.3.134
username: root username: root
password: 123456 password: 91isoft_xunda
\ No newline at end of file \ No newline at end of file
spring: spring:
profiles: profiles:
active: dev active: prod
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment