Commit 5041f9f2 authored by 赵啸非's avatar 赵啸非

修改部署脚本

parent 969a129b
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>setup-project-manager</artifactId> <artifactId>setup-project-manager</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<description>应用工程部署平台</description> <description>应用工程部署平台</description>
<parent> <parent>
<groupId>com.mortals.xhx</groupId> <groupId>com.mortals.xhx</groupId>
<artifactId>setup-project-platform</artifactId> <artifactId>setup-project-platform</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
<properties>
<common-lib.version>0.0.1-SNAPSHOT</common-lib.version>
<pcap4j.version>1.8.2</pcap4j.version>
<zxing.version>3.4.1</zxing.version>
<!-- 默认值 -->
<profiles.server.debug></profiles.server.debug>
<profiles.server.port>8081</profiles.server.port>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.nacosUrl>http://127.0.0.1:8848</profiles.nacosUrl>
<profiles.server.debug>21568</profiles.server.debug>
</properties>
<profiles> <properties>
<profile> <common-lib.version>0.0.1-SNAPSHOT</common-lib.version>
<id>develop</id> <pcap4j.version>1.8.2</pcap4j.version>
<activation> <zxing.version>3.4.1</zxing.version>
<activeByDefault>true</activeByDefault> <!-- 默认值 -->
</activation> <profiles.server.debug></profiles.server.debug>
<properties> <profiles.server.port>8081</profiles.server.port>
<profiles.active>develop</profiles.active> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.datasource.uri> <profiles.log.level>info</profiles.log.level>
<![CDATA[jdbc:mysql://localhost:3306/setup-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.datasource.username>root</profiles.datasource.username> <profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.datasource.password>12345678</profiles.datasource.password> <profiles.nacosUrl>http://127.0.0.1:8848</profiles.nacosUrl>
<profiles.publish.path>E:\pic\publish\</profiles.publish.path> <profiles.server.debug></profiles.server.debug>
</properties> </properties>
</profile>
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=25599</profiles.server.debug>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.98:3306/setup-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.publish.path>/home/publish/</profiles.publish.path>
</properties>
</profile>
<profile>
<id>product</id>
<properties>
</properties> <profiles>
</profile> <profile>
</profiles> <id>develop</id>
<dependencies> <activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profiles.active>develop</profiles.active>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://localhost:3306/setup-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>12345678</profiles.datasource.password>
<profiles.publish.path>E:\pic\publish\</profiles.publish.path>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=25599
</profiles.server.debug>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.98:3306/setup-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.publish.path>/home/publish/</profiles.publish.path>
</properties>
</profile>
<profile>
<id>product</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://127.0.0.1:3306/setup-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.publish.path>/home/publish/</profiles.publish.path>
</properties>
</profile>
</profiles>
<dependencies>
<dependency> <dependency>
<groupId>com.mortals.xhx</groupId> <groupId>com.mortals.xhx</groupId>
<artifactId>common-lib</artifactId> <artifactId>common-lib</artifactId>
</dependency> </dependency>
<!-- 引入 SpringMVC 相关依赖,并实现对其的自动配置 --> <!-- 引入 SpringMVC 相关依赖,并实现对其的自动配置 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId> <artifactId>druid-spring-boot-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.shalousun</groupId> <groupId>com.github.shalousun</groupId>
<artifactId>smart-doc</artifactId> <artifactId>smart-doc</artifactId>
<scope>test</scope> <scope>test</scope>
<version>2.3.0</version> <version>2.3.0</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.yaml</groupId> <groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.thoughtworks.qdox/qdox --> <!-- https://mvnrepository.com/artifact/com.thoughtworks.qdox/qdox -->
<dependency> <dependency>
<groupId>com.thoughtworks.qdox</groupId> <groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId> <artifactId>qdox</artifactId>
<version>2.0.1</version> <version>2.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.jsonzou</groupId> <groupId>com.github.jsonzou</groupId>
<artifactId>jmockdata</artifactId> <artifactId>jmockdata</artifactId>
<version>4.2.0</version> <version>4.2.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mapstruct</groupId> <groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <artifactId>mapstruct</artifactId>
<version>1.4.2.Final</version> <version>1.4.2.Final</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.freemarker</groupId> <groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId> <artifactId>freemarker</artifactId>
<version>2.3.31</version> <version>2.3.31</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.javafaker</groupId> <groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId> <artifactId>javafaker</artifactId>
...@@ -146,142 +152,142 @@ ...@@ -146,142 +152,142 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.deepoove</groupId> <groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId> <artifactId>poi-tl</artifactId>
<version>1.12.0</version> <version>1.12.0</version>
</dependency> </dependency>
<!-- <!--
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId> <artifactId>spring-expression</artifactId>
<version>5.3.18</version> <version>5.3.18</version>
<scope>provided</scope> <scope>provided</scope>
</dependency>--> </dependency>-->
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId> <artifactId>poi-scratchpad</artifactId>
<version>5.2.2</version> <version>5.2.2</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version> <version>2.19.1</version>
<configuration> <configuration>
<skipTests>true</skipTests> <!--默认关掉单元测试 --> <skipTests>true</skipTests> <!--默认关掉单元测试 -->
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>${java.version}</source> <source>${java.version}</source>
<target>${java.version}</target> <target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding> <encoding>${project.build.sourceEncoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<nonFilteredFileExtensions> <nonFilteredFileExtensions>
<nonFilteredFileExtension>docx</nonFilteredFileExtension> <nonFilteredFileExtension>docx</nonFilteredFileExtension>
</nonFilteredFileExtensions> </nonFilteredFileExtensions>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<id>copy-bin</id> <id>copy-bin</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
</goals> </goals>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<outputDirectory>target/bin <outputDirectory>target/bin
</outputDirectory> </outputDirectory>
<resources> <resources>
<resource> <resource>
<directory>src/main/bin/</directory> <directory>src/main/bin/</directory>
<excludes> <excludes>
<exclude>deploy.sh</exclude> <exclude>deploy.sh</exclude>
</excludes> </excludes>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
<id>copy-deploy</id> <id>copy-deploy</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
</goals> </goals>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}/ <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}/
</outputDirectory> </outputDirectory>
<resources> <resources>
<resource> <resource>
<directory>src/main/bin</directory> <directory>src/main/bin</directory>
<includes> <includes>
<include>deploy.sh</include> <include>deploy.sh</include>
</includes> </includes>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version> <version>3.3.0</version>
<executions> <executions>
<execution> <execution>
<id>make-assembly</id> <id>make-assembly</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>single</goal> <goal>single</goal>
</goals> </goals>
<configuration> <configuration>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId> <appendAssemblyId>false</appendAssemblyId>
<descriptors> <descriptors>
<descriptor>../assembly/assembly.xml</descriptor> <descriptor>../assembly/assembly.xml</descriptor>
</descriptors> </descriptors>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory> <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
...@@ -48,11 +48,13 @@ public class SetupDbServiceImpl implements SetupDbService { ...@@ -48,11 +48,13 @@ public class SetupDbServiceImpl implements SetupDbService {
druidDataSource.setPassword(dbSetupEntity.getPassword()); druidDataSource.setPassword(dbSetupEntity.getPassword());
DruidPooledConnection connection = druidDataSource.getConnection(); DruidPooledConnection connection = druidDataSource.getConnection();
createDatabase(connection, dbSetupEntity.getDbName()); boolean database = createDatabase(connection, dbSetupEntity.getDbName());
connection.setCatalog(dbSetupEntity.getDbName()); if(database){
FileSystemResource rc = new FileSystemResource(uploadService.getFilePath(dbSetupEntity.getDbFilePath())); connection.setCatalog(dbSetupEntity.getDbName());
EncodedResource er = new EncodedResource(rc, "UTF-8"); FileSystemResource rc = new FileSystemResource(uploadService.getFilePath(dbSetupEntity.getDbFilePath()));
ScriptUtils.executeSqlScript(connection, er); EncodedResource er = new EncodedResource(rc, "UTF-8");
ScriptUtils.executeSqlScript(connection, er);
}
} catch (Exception e) { } catch (Exception e) {
log.error("初始化数据库异常", e); log.error("初始化数据库异常", e);
......
...@@ -53,7 +53,6 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -53,7 +53,6 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
@Autowired @Autowired
private UploadService uploadService; private UploadService uploadService;
@Autowired @Autowired
private SetupDbService setupDbService; private SetupDbService setupDbService;
...@@ -102,6 +101,7 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -102,6 +101,7 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
dbSetupEntity.setUserName(setupProjectEntity.getDbUser()); dbSetupEntity.setUserName(setupProjectEntity.getDbUser());
dbSetupEntity.setPassword(setupProjectEntity.getDbPassword()); dbSetupEntity.setPassword(setupProjectEntity.getDbPassword());
dbSetupEntity.setDbFilePath(publicPath + "/db/base.sql"); dbSetupEntity.setDbFilePath(publicPath + "/db/base.sql");
log.info("数据库db路径!{}", dbSetupEntity.getDbFilePath());
Rest<String> dbRest = setupDbService.initDb(dbSetupEntity); Rest<String> dbRest = setupDbService.initDb(dbSetupEntity);
if (YesNoEnum.YES.getValue() != dbRest.getCode()) { if (YesNoEnum.YES.getValue() != dbRest.getCode()) {
log.info("数据库初始化成功!"); log.info("数据库初始化成功!");
...@@ -113,13 +113,13 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -113,13 +113,13 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
//判断当前系统类型,执行不同shell 或者 bat脚本 //判断当前系统类型,执行不同shell 或者 bat脚本
if(SystemUtil.getOsInfo().isLinux()){ if (SystemUtil.getOsInfo().isLinux()) {
//todo 执行部署脚本 //todo 执行部署脚本
//RuntimeUtil.exec() //RuntimeUtil.exec()
log.info("执行deploy shell 脚本 或者构造文件"); log.info("执行deploy shell 脚本 或者构造文件");
// callScript("deploy.sh","4",publicPath+"/bin/"); // callScript("deploy.sh","4",publicPath+"/bin/");
}else if(SystemUtil.getOsInfo().isWindows()){ } else if (SystemUtil.getOsInfo().isWindows()) {
//todo //todo
} }
...@@ -217,12 +217,12 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -217,12 +217,12 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
} }
private void callScript(String script, String args, String... workspace){ private void callScript(String script, String args, String... workspace) {
try { try {
String cmd = "sh " + script + " " + args; String cmd = "sh " + script + " " + args;
// String[] cmd = {"sh", script, "4"}; // String[] cmd = {"sh", script, "4"};
File dir = null; File dir = null;
if(workspace[0] != null){ if (workspace[0] != null) {
dir = new File(workspace[0]); dir = new File(workspace[0]);
System.out.println(workspace[0]); System.out.println(workspace[0]);
} }
...@@ -235,14 +235,12 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -235,14 +235,12 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
log.info(line); log.info(line);
} }
input.close(); input.close();
} } catch (Exception e) {
catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(FileUtil.getSuffix("test.tar.gz")); System.out.println(FileUtil.getSuffix("test.tar.gz"));
......
...@@ -322,7 +322,6 @@ setup_nginx() { ...@@ -322,7 +322,6 @@ setup_nginx() {
} }
setup_font() { setup_font() {
writelog "字体安装..." writelog "字体安装..."
yum install -y fontconfig mkfontscale yum install -y fontconfig mkfontscale
...@@ -477,12 +476,19 @@ nacos_deploy() { ...@@ -477,12 +476,19 @@ nacos_deploy() {
#todo 添加nginx 针对当前ip的sql stream代理 #todo 添加nginx 针对当前ip的sql stream代理
fi fi
#查看进程是否存在,如果存在 则不安装 #查看进程是否存在,如果存在 则不安装
project_status=$(systemctl status "${NACOS}" | grep Active | awk '{print $2}')
if [ -n "$project_status" ]; then #查看文件夹是否存在
echo "NACOS项目已经安装,状态: $project_status" if [ -d ${NACOS_EXECPATH} ]; then
writelog "NACOS项目已经安装!"
return return
fi fi
#project_status=$(systemctl status "${NACOS}" | grep Active | awk '{print $2}')
# if [ -n "$project_status" ]; then
# echo "NACOS项目已经安装,状态: $project_status"
# return
# fi
rm -rf ${NACOS_SERVICE} rm -rf ${NACOS_SERVICE}
rm -rf ${NACOS_EXECPATH} rm -rf ${NACOS_EXECPATH}
mkdir -p ${NACOS_EXECPATH} mkdir -p ${NACOS_EXECPATH}
...@@ -527,9 +533,14 @@ setup_project_deploy() { ...@@ -527,9 +533,14 @@ setup_project_deploy() {
build_nginx_mysql_stream $NGINX_CONF_PATH/mysql_stream.stream build_nginx_mysql_stream $NGINX_CONF_PATH/mysql_stream.stream
fi fi
project_status=$(systemctl status "${SETUP_PROJECT_PLATFORM}" | grep Active | awk '{print $2}') # project_status=$(systemctl status "${SETUP_PROJECT_PLATFORM}" | grep Active | awk '{print $2}')
if [ -n "$project_status" ]; then # if [ -n "$project_status" ]; then
writelog "工程已经安装,状态: $project_status" # writelog "工程已经安装,状态: $project_status"
# return
# fi
if [ -d ${SETUP_PROJECT_PLATFORM_EXECPATH} ]; then
writelog "项目部署工程已经安装!"
return return
fi fi
......
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