/**
* Deploy a web application
*
* @return
* @throws IOException
* @throws ServiceException
* @throws CheckException
*/
@ResponseBody
@RequestMapping(value = "/{applicationName}/deploy", method = RequestMethod.POST, consumes = {
"multipart/form-data" })
public JsonResponse deploy(@RequestPart("file") MultipartFile fileUpload, @PathVariable String applicationName,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServiceException, CheckException {
logger.info("applicationName = " + applicationName + "file = " + fileUpload.getOriginalFilename());
User user = authentificationUtils.getAuthentificatedUser();
Application application = applicationService.findByNameAndUser(user, applicationName);
// We must be sure there is no running action before starting new one
authentificationUtils.canStartNewAction(user, application, Locale.ENGLISH);
application = applicationService.deploy(fileUpload, application);
String needRestart = dockerService.getEnv(application.getServer().getContainerID(),
"CU_SERVER_RESTART_POST_DEPLOYMENT");
if ("true".equalsIgnoreCase(needRestart)){
// set the application in pending mode
applicationEventPublisher.publishEvent(new ApplicationPendingEvent(application));
applicationService.stop(application);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
applicationService.start(application);
// wait for modules and servers starting
applicationEventPublisher.publishEvent(new ApplicationStartEvent(application));
}
logger.info("--DEPLOY APPLICATION WAR ENDED--");
return new HttpOk();
}
ApplicationController.java 文件源码
java
阅读 53
收藏 0
点赞 0
评论 0
项目:devops-cstack
作者:
评论列表
文章目录