perf:移除插件代码
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -28,7 +28,6 @@
|
||||
<module>springboot-message</module>
|
||||
<module>springboot-encrypt</module>
|
||||
<module>springboot-annotation</module>
|
||||
<module>springboot-launcher</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
@@ -128,9 +127,6 @@
|
||||
<pluginRepository>
|
||||
<id>kepai-repo-plugin</id>
|
||||
<url>http://git.kepai365.com/zeng_wenhao/kepai-repo/raw/master</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
@@ -138,7 +134,7 @@
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-plugin</groupId>
|
||||
<artifactId>launcher-maven-plugin</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<executions>
|
||||
|
||||
@@ -29,16 +29,13 @@
|
||||
<repository>
|
||||
<id>kepai-repo</id>
|
||||
<url>http://git.kepai365.com/zeng_wenhao/kepai-repo/raw/master</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-plugin</groupId>
|
||||
<artifactId>launcher-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<artifactId>launcher-maven-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>0.0.2</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.tiesheng.launcher;
|
||||
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 指定调用本类execute()方法的目标
|
||||
**/
|
||||
@Mojo(name = "initScript", defaultPhase = LifecyclePhase.PREPARE_PACKAGE)
|
||||
public class CopyLauncherScriptMojo extends AbstractMojo {
|
||||
|
||||
@Parameter(defaultValue = "${basedir}/target", required = true)
|
||||
private File outputDirectory;
|
||||
|
||||
public void setOutputDirectory(File outputDirectory) {
|
||||
this.outputDirectory = outputDirectory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
try {
|
||||
copy("launchScript");
|
||||
System.out.println("initScript success.");
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("copy launchScript error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 复制脚本
|
||||
*
|
||||
* @param filename
|
||||
* @throws IOException
|
||||
*/
|
||||
private void copy(String filename) throws IOException {
|
||||
InputStream inputStream = getClass().getResourceAsStream("/" + filename);
|
||||
BufferedWriter writer = null;
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
File target = new File(outputDirectory + "/" + filename);
|
||||
target.setExecutable(true, false);
|
||||
target.setWritable(true, false);
|
||||
target.setReadable(true, false);
|
||||
writer = new BufferedWriter(new FileWriter(target));
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
writer.write(line);
|
||||
writer.newLine();
|
||||
}
|
||||
writer.flush();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# . ____ _ __ _ _
|
||||
# /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
|
||||
# ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
|
||||
# \\/ ___)| |_)| | | | | || (_| | ) ) ) )
|
||||
# ' |____| .__|_| |_|_| |_\__, | / / / /
|
||||
# =========|_|==============|___/=/_/_/_/
|
||||
# :: Spring Boot Startup Script ::
|
||||
#
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: {{initInfoProvides:spring-boot-application}}
|
||||
# Required-Start: {{initInfoRequiredStart:$remote_fs $syslog $network}}
|
||||
# Required-Stop: {{initInfoRequiredStop:$remote_fs $syslog $network}}
|
||||
# Default-Start: {{initInfoDefaultStart:2 3 4 5}}
|
||||
# Default-Stop: {{initInfoDefaultStop:0 1 6}}
|
||||
# Short-Description: {{initInfoShortDescription:Spring Boot Application}}
|
||||
# Description: {{initInfoDescription:Spring Boot Application}}
|
||||
# chkconfig: {{initInfoChkconfig:2345 99 01}}
|
||||
### END INIT INFO
|
||||
|
||||
[[ -n "$DEBUG" ]] && set -x
|
||||
|
||||
# Initialize variables that cannot be provided by a .conf file
|
||||
WORKING_DIR="$(pwd)"
|
||||
# shellcheck disable=SC2153
|
||||
[[ -n "$JARFILE" ]] && jarfile="$JARFILE"
|
||||
[[ -n "$APP_NAME" ]] && identity="$APP_NAME"
|
||||
|
||||
# Follow symlinks to find the real jar and detect init.d script
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
[[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
|
||||
while [[ -L "$jarfile" ]]; do
|
||||
[[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile")
|
||||
jarfile=$(readlink "$jarfile")
|
||||
cd "$(dirname "$jarfile")" || exit 1
|
||||
jarfile=$(pwd)/$(basename "$jarfile")
|
||||
done
|
||||
jarfolder="$( (cd "$(dirname "$jarfile")" && pwd -P) )"
|
||||
cd "$WORKING_DIR" || exit 1
|
||||
|
||||
# ANSI Colors
|
||||
echoRed() { echo $'\e[0;31m'"$1"$'\e[0m'; }
|
||||
echoGreen() { echo $'\e[0;32m'"$1"$'\e[0m'; }
|
||||
echoYellow() { echo $'\e[0;33m'"$1"$'\e[0m'; }
|
||||
|
||||
# Determine the user to run as if we are root
|
||||
# shellcheck disable=SC2012
|
||||
[[ $(id -u) == "0" ]] && run_user=$(ls -ld "$jarfile" | awk '{print $3}')
|
||||
|
||||
# Find Java
|
||||
if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
|
||||
javaexe="$JAVA_HOME/bin/java"
|
||||
elif type -p java > /dev/null 2>&1; then
|
||||
javaexe=$(type -p java)
|
||||
elif [[ -x "/usr/bin/java" ]]; then
|
||||
javaexe="/usr/bin/java"
|
||||
else
|
||||
echo "Unable to find Java"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
## 配置service
|
||||
service() {
|
||||
|
||||
tempCahr='$'
|
||||
|
||||
## 创建service文件
|
||||
working_dir=$(dirname "$jarfile")
|
||||
service_file="/etc/systemd/system/$1.service"
|
||||
|
||||
echo "[Unit]" > $service_file
|
||||
echo "Description=$1" >> $service_file
|
||||
echo "After=rc-local.service network.target remote-fs.target nss-lookup.target" >> $service_file
|
||||
|
||||
echo "" >> $service_file
|
||||
echo "[Service]" >> $service_file
|
||||
echo "Type=forking" >> $service_file
|
||||
echo "WorkingDirectory=$working_dir" >> $service_file
|
||||
echo "ExecStart=/bin/sh -c '$javaexe -Xms64m -Xmx128m -Dserver.port=$2 -Dspring.profiles.active=$3 -jar $jarfile > /dev/null 2>&1 &'" >> $service_file
|
||||
echo "ExecReload=/bin/kill -s HUP ${tempCahr}MAINPID" >> $service_file
|
||||
echo "ExecStop=/bin/kill -s QUIT ${tempCahr}MAINPID" >> $service_file
|
||||
|
||||
echo "" >> $service_file
|
||||
echo "[Install]" >> $service_file
|
||||
echo "WantedBy=multi-user.target" >> $service_file
|
||||
systemctl daemon-reload
|
||||
|
||||
## 自启动
|
||||
systemctl enable $1
|
||||
|
||||
## 配置成功
|
||||
echoGreen "config success, use 'systemctl start $1 ' to start"
|
||||
|
||||
}
|
||||
service "$@"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user