Sfoglia il codice sorgente

在应用项目的根目录下建立一个 bin 目录, 存放应用运行需要的脚本和构建得到的应用 jar 包
配置 pom.xml 文件将构建得到的应用 jar 包复制到 bin 目录

reghao 4 anni fa
parent
commit
cda17f8787

+ 4 - 0
dagent/bin/shutdown.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+pid=`jps | grep autodop-dagent.jar | awk '{print $1}'`
+kill -15 ${pid}

+ 4 - 0
dagent/bin/start.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+app_path='/opt/apps/dagent/autodop-dagent.jar'
+nohup java -jar ${app_path} > console.log 2>&1 &

+ 30 - 1
dagent/pom.xml

@@ -11,6 +11,10 @@
 
     <artifactId>dagent</artifactId>
 
+    <properties>
+        <project.build.outputDir>${project.basedir}/bin</project.build.outputDir>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>cn.reghao.autodop</groupId>
@@ -44,7 +48,7 @@
     </profiles>
 
     <build>
-        <finalName>autodop-dagent</finalName>
+        <finalName>${project.artifactId}</finalName>
 
         <extensions>
             <extension>
@@ -68,6 +72,31 @@
         </resources>
 
         <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>3.1.2</version>
+                <executions>
+                    <execution>
+                        <id>copy-artifact</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>${project.groupId}</groupId>
+                                    <artifactId>${project.artifactId}</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>${project.packaging}</type>
+                                </artifactItem>
+                            </artifactItems>
+                            <outputDirectory>${project.build.outputDir}</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>

+ 4 - 0
dmaster/bin/shutdown.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+pid=`jps | grep autodop-dmaster.jar | awk '{print $1}'`
+kill -15 ${pid}

+ 3 - 0
dmaster/bin/start.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+nohup java -jar /opt/apps/dmaster/autodop-dmaster.jar > console.log 2>&1 &

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/config/AppConfig.java

@@ -25,7 +25,7 @@ import javax.validation.constraints.NotNull;
 public class AppConfig extends BaseEntity<Integer> implements Cloneable {
     @Column(nullable = false, unique = true)
     @NotNull(message = "应用 ID 不能为 NULL")
-    @Length(min = 4, max = 64, message = "应用 ID 长度为 4 ~ 64 个字符")
+    @Length(min = 4, max = 64, message = "应用 ID 仅可包含数字,大小写字母和 '-' 等字符, 长度为 4 ~ 64 个字符")
     private String appId;
     @NotBlank(message = "应用名字不能为空白字符串")
     private String appName;

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/util/buildtool/packer/ZipPack.java

@@ -23,7 +23,7 @@ public class ZipPack implements CodePacker {
 
     @Override
     public String pack(String appId, String commitId, String appCompileHome) throws Exception {
-        String filename = String.format("%s-%s.zip", appId, commitId);
+        String filename = String.format("%s_%s.zip", appId, commitId);
         String dst = targetPath + "/" + filename;
         if (new File(dst).exists()) {
             throw new Exception(dst + " 已存在");