소스 검색

提交打包配置

chenken 7 년 전
부모
커밋
3fac22ea46

+ 1 - 0
.gitignore

@@ -8,3 +8,4 @@ org.eclipse.core.resources.prefs
 org.eclipse.jdt.core.prefs
 org.eclipse.m2e.core.prefs
 *.class
+target

+ 30 - 0
examcloud-task-starter/assembly.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+	<id>distribution</id>
+	<formats>
+		<format>zip</format>
+	</formats>
+	<fileSets>
+		<fileSet>
+			<directory>${project.basedir}/src/main/resources</directory>
+			<outputDirectory>/config</outputDirectory>
+		</fileSet>
+		<fileSet>
+			<directory>${project.basedir}/shell</directory>
+			<excludes>
+				<exclude>start.args</exclude>
+				<exclude>start.vmoptions</exclude>
+			</excludes>
+			<outputDirectory>/</outputDirectory>
+			<fileMode>0777</fileMode>
+		</fileSet>
+	</fileSets>
+	<dependencySets>
+		<dependencySet>
+			<useProjectArtifact>true</useProjectArtifact>
+			<outputDirectory>lib</outputDirectory>
+			<scope>runtime</scope>
+		</dependencySet>
+	</dependencySets>
+</assembly>

+ 76 - 0
examcloud-task-starter/pom.xml

@@ -18,4 +18,80 @@
 			<artifactId>spring-boot-starter-test</artifactId>
 		</dependency>
   </dependencies>
+   <!-- 打包成zip -->
+  	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<configuration>
+					<archive>
+						<manifest>
+							<mainClass>cn.com.qmth.task.starter.TaskApplication</mainClass>
+							<addClasspath>true</addClasspath>
+							<classpathPrefix>./</classpathPrefix>
+						</manifest>
+						<manifestEntries>
+							<Class-Path>../config/</Class-Path>
+						</manifestEntries>
+					</archive>
+					<excludes>
+						<exclude>*.properties</exclude>
+						<exclude>*.xml </exclude>
+						<exclude>*.conf </exclude>
+					</excludes>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<finalName>examcloud-task</finalName>
+					<descriptors>
+						<descriptor>assembly.xml</descriptor>
+					</descriptors>
+				</configuration>
+				<executions>
+					<execution>
+						<id>make-assembly</id>
+						<phase>install</phase>
+						<goals>
+							<goal>assembly</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+	<!-- 
+	打成jar包
+	<build>  
+		<finalName>examcloud-task</finalName>
+		<plugins>  
+		    <plugin>  
+		        <groupId>org.springframework.boot</groupId>  
+		        <artifactId>spring-boot-maven-plugin</artifactId>  
+		        <configuration>  
+                	<fork>true</fork>  
+                	<mainClass>cn.com.qmth.task.starter.TaskApplication</mainClass> 主类 包含main
+                	<layout>JAR</layout> -包类型(必须大写) JAR,WAR,ZIP,MODULE,NONE
+            	</configuration>
+            	<executions>
+					<execution>
+						<goals>
+							<goal>repackage</goal>
+						</goals>
+					</execution>
+				</executions>
+		    </plugin>  
+		    <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+		</plugins>  
+	 </build>   -->
 </project>

+ 1 - 0
examcloud-task-starter/shell/start.args

@@ -0,0 +1 @@
+--spring.profiles.active=test

+ 27 - 0
examcloud-task-starter/shell/start.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+
+APP_MAIN_JAR="examcloud-task-starter-2.0-SNAPSHOT.jar"
+
+FILE_PATH=$(cd `dirname $0`; pwd)
+
+JAVA_OPTS=`cat $FILE_PATH/start.vmoptions`
+APP_ARGS=`cat $FILE_PATH/start.args`
+
+PID_LIST=`ps -ef|grep $APP_MAIN_JAR|grep java|awk '{print $2}'`
+
+if [ ! -z "$PID_LIST" ]; then
+    echo "[ERROR] : APP is already running!"
+    exit -1
+fi
+
+echo "java options:"
+echo "$JAVA_OPTS"
+echo "args:"
+echo "$APP_ARGS"
+    
+nohup java $JAVA_OPTS -jar $FILE_PATH/lib/$APP_MAIN_JAR $APP_ARGS >/dev/null 2>&1 &
+
+echo "starting......"
+
+exit 0
+

+ 1 - 0
examcloud-task-starter/shell/start.vmoptions

@@ -0,0 +1 @@
+-server -Xms512m -Xmx512m

+ 18 - 0
examcloud-task-starter/shell/stop.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+APP_MAIN_JAR="examcloud-task-starter-2.0-SNAPSHOT.jar"
+
+FILE_PATH=$(cd `dirname $0`; pwd)
+
+PID_LIST=`ps -ef|grep $APP_MAIN_JAR|grep java|awk '{print $2}'`
+
+if [ ! -z "$PID_LIST" ]; then
+    echo "Runnable jar is $APP_MAIN_JAR."
+    for PID in $PID_LIST 
+    do
+        kill -9 $PID
+    done
+    echo "stopped !"
+fi
+
+exit 0