//package com.css.simulation.resource.scheduler.agent.app.service;
//
//import api.common.util.FileUtil;
//import api.common.util.OsUtil;
//import lombok.SneakyThrows;
//import org.springframework.stereotype.Service;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.File;
//
//@Service
//public class TaskAppService {
//
//  private static final String rootPath = "/opt/data/";
//  private static final String upCommandOfDockerCompose = "docker-compose -f filename up -d";
//  private static final String downCommandOfDockerCompose = "docker-compose -f docker-compose.yml down";
//
//  public void saveDockerComposeYamlOfTask(MultipartFile file) {
//    //1 解析文件名获取项目ID
//    final String fileName = file.getName();
//    final String projectId = SchedulerUtil.getProjectIdFromYamlName(fileName);
//    //2 保存文件
//    FileUtil.writeMultipartFileToLocalFile(file, rootPath + projectId + File.separator + fileName);
//  }
//
//  @SneakyThrows
//  public void upDockerComposeYamlOfOneTaskOfProject(String projectId) {
//    final File file = FileUtil.getRandomFileOfDirectory(rootPath + projectId);
//    OsUtil.exec(upCommandOfDockerCompose.replace("filename", file.getAbsolutePath()));
//  }
//
//  @SneakyThrows
//  public void downDockerComposeYamlOfOneTaskOfProject(String yamlName) {
//    OsUtil.exec(downCommandOfDockerCompose.replace("filename", rootPath + yamlName));
//  }
//}
