Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8bc11d456 | ||
|
|
1ea7fa968b | ||
|
|
c892fec45b | ||
|
|
7e94ea54a8 | ||
|
|
d006788c90 | ||
|
|
c63a6769ad | ||
|
|
156cce877b | ||
|
|
49d88ee08f | ||
|
|
88777898c4 | ||
|
|
3f59d00092 | ||
|
|
2e8969f249 | ||
|
|
ebb99ced78 | ||
|
|
e862cdbf43 | ||
|
|
d6faed4f68 | ||
|
|
ec4b0cbb1e | ||
|
|
30fd68d430 | ||
|
|
ec865471cb | ||
|
|
7d454e9c62 |
@@ -9,6 +9,9 @@ deploy-jar:
|
|||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
script:
|
script:
|
||||||
|
- cd springboot-launcher
|
||||||
|
- mvn clean install
|
||||||
|
- cd ..
|
||||||
- mvn clean deploy -Dmaven.test.skip -DaltDeploymentRepository=master::default::file:/usr/local/nginx/html/kepai-repo
|
- mvn clean deploy -Dmaven.test.skip -DaltDeploymentRepository=master::default::file:/usr/local/nginx/html/kepai-repo
|
||||||
- cd /usr/local/nginx/html/kepai-repo
|
- cd /usr/local/nginx/html/kepai-repo
|
||||||
- git checkout master
|
- git checkout master
|
||||||
|
|||||||
52
pom.xml
52
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
<module>springboot-message</module>
|
<module>springboot-message</module>
|
||||||
<module>springboot-encrypt</module>
|
<module>springboot-encrypt</module>
|
||||||
<module>springboot-annotation</module>
|
<module>springboot-annotation</module>
|
||||||
|
<module>springboot-launcher</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -57,55 +58,55 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-db-migration</artifactId>
|
<artifactId>springboot-db-migration</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -120,8 +121,37 @@
|
|||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.tiesheng</groupId>
|
||||||
|
<artifactId>launcher-maven-plugin</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>initScript</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<!-- 把外部jar打包进入项目中 -->
|
||||||
|
<includeSystemScope>true</includeSystemScope>
|
||||||
|
<!-- 打包后的jar可直接执行 -->
|
||||||
|
<executable>true</executable>
|
||||||
|
<embeddedLaunchScript>${basedir}/target/launchScript</embeddedLaunchScript>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
@@ -37,6 +37,10 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.tiesheng</groupId>
|
||||||
|
<artifactId>launcher-maven-plugin</artifactId>
|
||||||
|
</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>
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
package com.tiesheng.demo.config;
|
package com.tiesheng.demo.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.core.pojos.CurrentWebUser;
|
import com.tiesheng.core.pojos.CurrentWebUser;
|
||||||
|
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
||||||
import com.tiesheng.core.service.TieshengWebConfigurer;
|
import com.tiesheng.core.service.TieshengWebConfigurer;
|
||||||
|
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||||
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DemoWebConfigurer implements TieshengWebConfigurer {
|
public class DemoWebConfigurer implements TieshengWebConfigurer {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
GlobalConfig globalConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentWebUser getCurrentUserName(String userId) {
|
public CurrentWebUser getCurrentUserName(String userId) {
|
||||||
return null;
|
return null;
|
||||||
@@ -14,6 +25,29 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginConfigurer loginConfigurer() {
|
public LoginConfigurer loginConfigurer() {
|
||||||
return null;
|
return new LoginConfigurer() {
|
||||||
|
@Override
|
||||||
|
public TokenBean doLogin(CorePlatformUnique platformUnique, String to) {
|
||||||
|
|
||||||
|
// 默认跳转到mobile
|
||||||
|
to = StrUtil.emptyToDefault(to, "mobile");
|
||||||
|
|
||||||
|
TokenBean tokenBean = null;
|
||||||
|
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
|
||||||
|
tokenBean = new TokenBean(platformUnique.getUserId(), to, globalConfig.getService());
|
||||||
|
} else {
|
||||||
|
// 获取用户信息判断是否可登录
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokenBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||||
|
if (Objects.equals(bean.getEnvironmentType(), "mobile")) {
|
||||||
|
globalConfig.redirect("mobile", "/?token=" + bean.toToken(), response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-db-migration</artifactId>
|
<artifactId>springboot-db-migration</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
|||||||
32
springboot-launcher/pom.xml
Normal file
32
springboot-launcher/pom.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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.1</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>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
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");
|
||||||
|
} 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
256
springboot-launcher/src/main/resources/launchScript
Normal file
256
springboot-launcher/src/main/resources/launchScript
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
# Source any config file
|
||||||
|
configfile="$(basename "${jarfile%.*}.conf")"
|
||||||
|
|
||||||
|
# Initialize CONF_FOLDER location defaulting to jarfolder
|
||||||
|
[[ -z "$CONF_FOLDER" ]] && CONF_FOLDER="{{confFolder:${jarfolder}}}"
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
[[ -r "${CONF_FOLDER}/${configfile}" ]] && source "${CONF_FOLDER}/${configfile}"
|
||||||
|
|
||||||
|
# Initialize PID/LOG locations if they weren't provided by the config file
|
||||||
|
[[ -z "$PID_FOLDER" ]] && PID_FOLDER="{{pidFolder:/var/run}}"
|
||||||
|
[[ -z "$LOG_FOLDER" ]] && LOG_FOLDER="{{logFolder:/var/log}}"
|
||||||
|
! [[ "$PID_FOLDER" == /* ]] && PID_FOLDER="$(dirname "$jarfile")"/"$PID_FOLDER"
|
||||||
|
! [[ "$LOG_FOLDER" == /* ]] && LOG_FOLDER="$(dirname "$jarfile")"/"$LOG_FOLDER"
|
||||||
|
! [[ -x "$PID_FOLDER" ]] && PID_FOLDER="/tmp"
|
||||||
|
! [[ -x "$LOG_FOLDER" ]] && LOG_FOLDER="/tmp"
|
||||||
|
|
||||||
|
# Set up defaults
|
||||||
|
[[ -z "$MODE" ]] && MODE="{{mode:auto}}" # modes are "auto", "service" or "run"
|
||||||
|
[[ -z "$USE_START_STOP_DAEMON" ]] && USE_START_STOP_DAEMON="{{useStartStopDaemon:true}}"
|
||||||
|
|
||||||
|
# Create an identity for log/pid files
|
||||||
|
if [[ -z "$identity" ]]; then
|
||||||
|
if [[ -n "$init_script" ]]; then
|
||||||
|
identity="${init_script}"
|
||||||
|
else
|
||||||
|
identity=$(basename "${jarfile%.*}")_${jarfolder//\//}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize log file name if not provided by the config file
|
||||||
|
[[ -z "$LOG_FILENAME" ]] && LOG_FILENAME="{{logFilename:${identity}.log}}"
|
||||||
|
|
||||||
|
# Initialize stop wait time if not provided by the config file
|
||||||
|
[[ -z "$STOP_WAIT_TIME" ]] && STOP_WAIT_TIME="{{stopWaitTime:60}}"
|
||||||
|
|
||||||
|
# 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'; }
|
||||||
|
|
||||||
|
# Utility functions
|
||||||
|
checkPermissions() {
|
||||||
|
touch "$pid_file" &> /dev/null || { echoRed "Operation not permitted (cannot access pid file)"; return 4; }
|
||||||
|
touch "$log_file" &> /dev/null || { echoRed "Operation not permitted (cannot access log file)"; return 4; }
|
||||||
|
}
|
||||||
|
|
||||||
|
isRunning() {
|
||||||
|
ps -p "$1" | grep -v "PID" &> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
await_file() {
|
||||||
|
end=$(date +%s)
|
||||||
|
let "end+=10"
|
||||||
|
while [[ ! -s "$1" ]]
|
||||||
|
do
|
||||||
|
now=$(date +%s)
|
||||||
|
if [[ $now -ge $end ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine the script mode
|
||||||
|
action="config"
|
||||||
|
if [[ "$MODE" == "auto" && -n "$init_script" ]] || [[ "$MODE" == "service" ]]; then
|
||||||
|
action="$1"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the pid and log filenames
|
||||||
|
PID_FOLDER="$PID_FOLDER/${identity}"
|
||||||
|
pid_file="$PID_FOLDER/{{pidFilename:${identity}.pid}}"
|
||||||
|
log_file="$LOG_FOLDER/$LOG_FILENAME"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar "$jarfile" $RUN_ARGS "$@")
|
||||||
|
|
||||||
|
# Action functions
|
||||||
|
start() {
|
||||||
|
if [[ -f "$pid_file" ]]; then
|
||||||
|
pid=$(cat "$pid_file")
|
||||||
|
isRunning "$pid" && { echoYellow "Already running [$pid]"; return 0; }
|
||||||
|
fi
|
||||||
|
do_start "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_start() {
|
||||||
|
working_dir=$(dirname "$jarfile")
|
||||||
|
pushd "$working_dir" > /dev/null
|
||||||
|
mkdir -p "$PID_FOLDER" &> /dev/null
|
||||||
|
if [[ -n "$run_user" ]]; then
|
||||||
|
checkPermissions || return $?
|
||||||
|
chown "$run_user" "$PID_FOLDER"
|
||||||
|
chown "$run_user" "$pid_file"
|
||||||
|
chown "$run_user" "$log_file"
|
||||||
|
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then
|
||||||
|
start-stop-daemon --start --quiet \
|
||||||
|
--chuid "$run_user" \
|
||||||
|
--name "$identity" \
|
||||||
|
--make-pidfile --pidfile "$pid_file" \
|
||||||
|
--background --no-close \
|
||||||
|
--startas "$javaexe" \
|
||||||
|
--chdir "$working_dir" \
|
||||||
|
-- "${arguments[@]}" \
|
||||||
|
>> "$log_file" 2>&1
|
||||||
|
await_file "$pid_file"
|
||||||
|
else
|
||||||
|
su -s /bin/sh -c "$javaexe $(printf "\"%s\" " "${arguments[@]}") >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file"
|
||||||
|
fi
|
||||||
|
pid=$(cat "$pid_file")
|
||||||
|
else
|
||||||
|
checkPermissions || return $?
|
||||||
|
"$javaexe" "${arguments[@]}" >> "$log_file" 2>&1 &
|
||||||
|
pid=$!
|
||||||
|
disown $pid
|
||||||
|
echo "$pid" > "$pid_file"
|
||||||
|
fi
|
||||||
|
[[ -z $pid ]] && { echoRed "Failed to start"; return 1; }
|
||||||
|
echoGreen "Started [$pid]"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
working_dir=$(dirname "$jarfile")
|
||||||
|
pushd "$working_dir" > /dev/null
|
||||||
|
[[ -f $pid_file ]] || { echoYellow "Not running (pidfile not found)"; return 0; }
|
||||||
|
pid=$(cat "$pid_file")
|
||||||
|
isRunning "$pid" || { echoYellow "Not running (process ${pid}). Removing stale pid file."; rm -f "$pid_file"; return 0; }
|
||||||
|
do_stop "$pid" "$pid_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_stop() {
|
||||||
|
kill "$1" &> /dev/null || { echoRed "Unable to kill process $1"; return 1; }
|
||||||
|
for i in $(seq 1 $STOP_WAIT_TIME); do
|
||||||
|
isRunning "$1" || { echoGreen "Stopped [$1]"; rm -f "$2"; return 0; }
|
||||||
|
[[ $i -eq STOP_WAIT_TIME/2 ]] && kill "$1" &> /dev/null
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echoRed "Unable to kill process $1";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
restart() {
|
||||||
|
stop && start
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
working_dir=$(dirname "$jarfile")
|
||||||
|
pushd "$working_dir" > /dev/null
|
||||||
|
[[ -f "$pid_file" ]] || { echoRed "Not running"; return 3; }
|
||||||
|
pid=$(cat "$pid_file")
|
||||||
|
isRunning "$pid" || { echoRed "Not running (process ${pid} not found)"; return 1; }
|
||||||
|
echoGreen "Running [$pid]"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
run() {
|
||||||
|
pushd "$(dirname "$jarfile")" > /dev/null
|
||||||
|
"$javaexe" "${arguments[@]}"
|
||||||
|
result=$?
|
||||||
|
popd > /dev/null
|
||||||
|
return "$result"
|
||||||
|
}
|
||||||
|
|
||||||
|
config() {
|
||||||
|
|
||||||
|
## 设置自启动
|
||||||
|
ln -s $jarfile /etc/init.d/$1
|
||||||
|
chkconfig --add $1
|
||||||
|
|
||||||
|
## 生成配置文件
|
||||||
|
working_dir=$(dirname "$jarfile")
|
||||||
|
conf_file="$working_dir/$configfile"
|
||||||
|
echo "LOG_FOLDER=/dev" > $conf_file
|
||||||
|
echo "LOG_FILENAME=null" >> $conf_file
|
||||||
|
echo "RUN_ARGS='--server.port=$2 --spring.profiles.active=$3'" >> $conf_file
|
||||||
|
echo "JAVA_OPTS='-Dfile.encoding=utf-8'" >> $conf_file
|
||||||
|
}
|
||||||
|
|
||||||
|
# Call the appropriate action function
|
||||||
|
case "$action" in
|
||||||
|
start)
|
||||||
|
start "$@"; exit $?;;
|
||||||
|
stop)
|
||||||
|
stop "$@"; exit $?;;
|
||||||
|
restart)
|
||||||
|
restart "$@"; exit $?;;
|
||||||
|
status)
|
||||||
|
status "$@"; exit $?;;
|
||||||
|
run)
|
||||||
|
run "$@"; exit $?;;
|
||||||
|
config)
|
||||||
|
config "$1" "$2" "$3" ; exit $?;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|status|run|config}"; exit 1;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.tiesheng.login.pojos;
|
package com.tiesheng.login.pojos;
|
||||||
|
|
||||||
public class CodeExtraDTO {
|
public class CodeExtraDTO extends LoginToInfo {
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String extra;
|
private String extra;
|
||||||
private String to;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
@@ -26,11 +25,4 @@ public class CodeExtraDTO {
|
|||||||
this.extra = extra;
|
this.extra = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTo() {
|
|
||||||
return to;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTo(String to) {
|
|
||||||
this.to = to;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.tiesheng.login.pojos;
|
||||||
|
|
||||||
|
public class LoginToInfo {
|
||||||
|
|
||||||
|
private String to;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getTo() {
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTo(String to) {
|
||||||
|
this.to = to;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,10 +2,9 @@ package com.tiesheng.login.pojos;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
public class UniqueIndexDTO {
|
public class UniqueIndexDTO extends LoginToInfo {
|
||||||
|
|
||||||
private String no;
|
private String no;
|
||||||
private String to;
|
|
||||||
private String extra;
|
private String extra;
|
||||||
private String info;
|
private String info;
|
||||||
|
|
||||||
@@ -21,14 +20,6 @@ public class UniqueIndexDTO {
|
|||||||
this.no = no;
|
this.no = no;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTo() {
|
|
||||||
return to;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTo(String to) {
|
|
||||||
this.to = to;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExtra() {
|
public String getExtra() {
|
||||||
if (StrUtil.isEmpty(extra)) {
|
if (StrUtil.isEmpty(extra)) {
|
||||||
extra = "";
|
extra = "";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ public class ToolController {
|
|||||||
*/
|
*/
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
@PostMapping("/file/chunk_merge")
|
@PostMapping("/file/chunk_merge")
|
||||||
public ApiResp<String> fileChunkMerge(String fileMd5) {
|
public ApiResp<String> fileChunkMerge(String fileMd5, String fileExt) {
|
||||||
String path = fileUploadService.chunkMerge(fileMd5);
|
String path = fileUploadService.chunkMerge(fileMd5, fileExt);
|
||||||
return ApiResp.respOK(path);
|
return ApiResp.respOK(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class FileUploadService {
|
|||||||
String fileType = FileTypeUtil.getType(file.getInputStream(), file.getOriginalFilename());
|
String fileType = FileTypeUtil.getType(file.getInputStream(), file.getOriginalFilename());
|
||||||
tieshengWebConfigurer.uploadFileCheck(fileType);
|
tieshengWebConfigurer.uploadFileCheck(fileType);
|
||||||
|
|
||||||
FileUploadPath filePath = FileUploadPath.random();
|
FileUploadPath filePath = FileUploadPath.random(fileType);
|
||||||
|
|
||||||
InputStream stream = file.getInputStream();
|
InputStream stream = file.getInputStream();
|
||||||
FileUtil.writeFromStream(stream, filePath.getAbsolutePath());
|
FileUtil.writeFromStream(stream, filePath.getAbsolutePath());
|
||||||
@@ -107,7 +107,7 @@ public class FileUploadService {
|
|||||||
*
|
*
|
||||||
* @param fileMd5
|
* @param fileMd5
|
||||||
*/
|
*/
|
||||||
public String chunkMerge(String fileMd5) {
|
public String chunkMerge(String fileMd5, String fileExt) {
|
||||||
|
|
||||||
// 1,获取文件块的目录
|
// 1,获取文件块的目录
|
||||||
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
||||||
@@ -118,7 +118,7 @@ public class FileUploadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3,生成保存文件的路径
|
// 3,生成保存文件的路径
|
||||||
FileUploadPath uploadPath = FileUploadPath.random();
|
FileUploadPath uploadPath = FileUploadPath.random(fileExt);
|
||||||
|
|
||||||
// 4,获取块文件,此列表是已经排好序的列表
|
// 4,获取块文件,此列表是已经排好序的列表
|
||||||
List<File> chunkFiles = getSortedChunkFiles(new File(folder.getAbsolutePath()));
|
List<File> chunkFiles = getSortedChunkFiles(new File(folder.getAbsolutePath()));
|
||||||
|
|||||||
Reference in New Issue
Block a user