nili
3 years ago
commit
9b5598f970
33 changed files with 1249 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||
.idea |
|||
**/*/target |
|||
**/*/logs |
|||
*.iml |
|||
**/*/pid |
|||
**/*/idl/gen-java |
|||
*.log |
|||
*.DS_Store |
|||
logs |
|||
pid |
|||
system.conf |
|||
jar |
@ -0,0 +1,41 @@ |
|||
#!/bin/bash |
|||
|
|||
mode=`cat system.conf | awk -F = '{print$2}'` |
|||
|
|||
if [ -z "$mode" ]; then |
|||
echo "mode is not set" |
|||
exit 1 |
|||
fi |
|||
|
|||
project=`echo $mode | awk -F - '{print $1}'` |
|||
|
|||
if [ -z "$project" ]; then |
|||
echo "mode format is wrong" |
|||
exit 1 |
|||
fi |
|||
|
|||
logdir=/var/www/data/log/luigi/$project |
|||
if [ ! -d "$logdir" ];then |
|||
mkdir -p $logdir |
|||
fi |
|||
|
|||
jardir=jar |
|||
if [ ! -d "$jardir" ];then |
|||
mkdir $jardir |
|||
fi |
|||
|
|||
|
|||
rm -rf logs |
|||
ln -s $logdir logs |
|||
|
|||
|
|||
mvn clean package -DskipTests -U > /dev/null |
|||
|
|||
r=$? |
|||
if [ "$r" == "0" ] ; then |
|||
echo 'build success' |
|||
else |
|||
echo 'build fail' |
|||
exit 1 |
|||
fi |
|||
|
@ -0,0 +1,84 @@ |
|||
<?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"> |
|||
<parent> |
|||
<artifactId>luigi</artifactId> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>luigi-api</artifactId> |
|||
|
|||
<properties> |
|||
<maven.compiler.source>17</maven.compiler.source> |
|||
<maven.compiler.target>17</maven.compiler.target> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-aop</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.squareup.okhttp3</groupId> |
|||
<artifactId>okhttp</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.google.code.gson</groupId> |
|||
<artifactId>gson</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<artifactId>common</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.google.guava</groupId> |
|||
<artifactId>guava</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.apache.commons</groupId> |
|||
<artifactId>commons-collections4</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<artifactId>luigi-dao</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> |
|||
<dependency> |
|||
<groupId>org.apache.commons</groupId> |
|||
<artifactId>commons-lang3</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/junit/junit --> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>redis.clients</groupId> |
|||
<artifactId>jedis</artifactId> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</project> |
@ -0,0 +1,26 @@ |
|||
package com.bzgame.server.luigi; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.boot.context.ApplicationPidFileWriter; |
|||
import org.springframework.boot.web.servlet.ServletComponentScan; |
|||
import org.springframework.context.annotation.ComponentScan; |
|||
import org.springframework.context.annotation.EnableAspectJAutoProxy; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@SpringBootApplication |
|||
@ComponentScan({"com.bzgame.server.luigi.service", |
|||
"com.bzgame.server.luigi.dao", |
|||
"com.bzgame.server.luigi.api"}) |
|||
@ServletComponentScan |
|||
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true) |
|||
public class ApiApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication application = new SpringApplication(ApiApplication.class); |
|||
application.addListeners(new ApplicationPidFileWriter()); |
|||
application.run(args); |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.bzgame.server.luigi.api; |
|||
|
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author nidaren |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/api/luigi") |
|||
public class HelloController { |
|||
@GetMapping("hello") |
|||
public String hello() { |
|||
return "hello, luigi"; |
|||
} |
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.bzgame.server.luigi.api; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.util.Assert; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
public class RequestContext { |
|||
|
|||
private static final String KEY_REQUEST = "request"; |
|||
|
|||
private static final String KEY_RESPONSE = "response"; |
|||
|
|||
private static final String KEY_UID = "uid"; |
|||
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(RequestContext.class); |
|||
|
|||
private static final ThreadLocal<Map<String, Object>> THREAD_LOCAL = new ThreadLocal<>(); |
|||
|
|||
|
|||
public static void init(HttpServletRequest request, HttpServletResponse response, Integer uid) { |
|||
|
|||
Assert.notNull(request, "request is null"); |
|||
Map<String, Object> context = new HashMap<>(); |
|||
context.put(KEY_REQUEST, request); |
|||
context.put(KEY_RESPONSE, response); |
|||
context.put(KEY_UID, uid); |
|||
THREAD_LOCAL.set(context); |
|||
} |
|||
|
|||
public static HttpServletRequest getRequest() { |
|||
|
|||
return (HttpServletRequest) THREAD_LOCAL.get().get(KEY_REQUEST); |
|||
} |
|||
|
|||
public static HttpServletResponse getResponse() { |
|||
|
|||
return (HttpServletResponse) THREAD_LOCAL.get().get(KEY_RESPONSE); |
|||
} |
|||
|
|||
|
|||
public static Integer getUid() { |
|||
return (Integer) THREAD_LOCAL.get().get(KEY_UID); |
|||
} |
|||
|
|||
public static String getUidStr() { |
|||
Integer uid = (Integer) THREAD_LOCAL.get().get(KEY_UID); |
|||
if (uid == null) { |
|||
return "empty"; |
|||
} |
|||
return uid + ""; |
|||
} |
|||
|
|||
public static void clear() { |
|||
THREAD_LOCAL.remove(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,109 @@ |
|||
package com.bzgame.server.luigi.api.aop; |
|||
|
|||
import com.bczgame.server.common.exception.BizException; |
|||
import com.bczgame.server.common.exception.ExceptionCode; |
|||
import com.bczgame.server.common.log.L; |
|||
import com.bczgame.server.common.log.Status; |
|||
import com.bczgame.server.common.vo.Response; |
|||
import com.bzgame.server.luigi.api.RequestContext; |
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.aspectj.lang.ProceedingJoinPoint; |
|||
import org.aspectj.lang.annotation.Around; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Aspect |
|||
@Component |
|||
public class ApiAop { |
|||
|
|||
private static final String EMPTY_STR_IN_LOG = "EMPTY"; |
|||
|
|||
@Value("${spring.application.name}") |
|||
private String appName; |
|||
|
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
|
|||
|
|||
@Around("@annotation(com.bzgame.server.luigi.api.aop.ApiFlag)") |
|||
public Object advice(ProceedingJoinPoint joinPoint) { |
|||
|
|||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|||
String methodName = signature.getMethod().getName(); |
|||
ApiFlag flag = signature.getMethod().getAnnotation(ApiFlag.class); |
|||
boolean log = flag.log(); |
|||
boolean logRet = flag.logRet(); |
|||
boolean logParam = flag.logParam(); |
|||
boolean needLogin = flag.needLogin(); |
|||
|
|||
Throwable exception = null; |
|||
long start = System.currentTimeMillis(); |
|||
Object[] params = joinPoint.getArgs(); |
|||
Object ret = null; |
|||
Status status = Status.SUCCESS; |
|||
try { |
|||
if (needLogin && RequestContext.getUid() == null) { |
|||
throw new BizException(ExceptionCode.NEED_AUTH, "请先登陆"); |
|||
} |
|||
ret = joinPoint.proceed(); |
|||
return ret; |
|||
} catch (Throwable e) { |
|||
exception = e; |
|||
|
|||
Response resp = new Response(); |
|||
resp.setMessage(e.getMessage()); |
|||
if (e instanceof BizException) { |
|||
resp.setCode(((BizException) e).getCode()); |
|||
} else if (e instanceof IllegalArgumentException) { |
|||
resp.setCode(ExceptionCode.PARAM_ILLEGAL_WARN); |
|||
resp.setMessage("服务器错误,请稍后重试"); |
|||
} else { |
|||
status = Status.FAILED; |
|||
resp.setCode(ExceptionCode.GENERAL_ERROR); |
|||
resp.setMessage("服务器错误,请稍后重试"); |
|||
} |
|||
|
|||
ret = resp; |
|||
return resp; |
|||
|
|||
} finally { |
|||
if (log) { |
|||
|
|||
int cost = (int) (System.currentTimeMillis() - start); |
|||
|
|||
String paramStr = EMPTY_STR_IN_LOG; |
|||
if (logParam && params != null && params.length > 0) { |
|||
try { |
|||
paramStr = objectMapper.writeValueAsString(params); |
|||
} catch (JsonProcessingException e) { |
|||
} |
|||
} |
|||
String retStr = EMPTY_STR_IN_LOG; |
|||
if (logRet && ret != null) { |
|||
try { |
|||
retStr = objectMapper.writeValueAsString(ret); |
|||
} catch (JsonProcessingException e) { |
|||
} |
|||
} |
|||
String cookiesStr = EMPTY_STR_IN_LOG; |
|||
if (RequestContext.getRequest().getCookies() != null && RequestContext.getRequest().getCookies().length > 0) { |
|||
try { |
|||
cookiesStr = objectMapper.writeValueAsString(RequestContext.getRequest().getCookies()); |
|||
} catch (JsonProcessingException e) { |
|||
} |
|||
} |
|||
|
|||
if (exception == null) { |
|||
L.api(cost, status, methodName, RequestContext.getUidStr(), cookiesStr, paramStr, retStr); |
|||
} else { |
|||
L.api(cost, status, methodName, RequestContext.getUidStr(), cookiesStr, paramStr, retStr, exception); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.bzgame.server.luigi.api.aop; |
|||
|
|||
|
|||
import java.lang.annotation.ElementType; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.RetentionPolicy; |
|||
import java.lang.annotation.Target; |
|||
|
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface ApiFlag { |
|||
|
|||
public boolean log() default true; |
|||
|
|||
public boolean logParam() default true; |
|||
|
|||
public boolean logRet() default true; |
|||
|
|||
public boolean needLogin() default false; |
|||
|
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.bzgame.server.luigi.api.config; |
|||
|
|||
import org.apache.catalina.Context; |
|||
import org.apache.catalina.connector.Connector; |
|||
import org.apache.coyote.http11.AbstractHttp11Protocol; |
|||
import org.apache.tomcat.util.http.LegacyCookieProcessor; |
|||
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; |
|||
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer; |
|||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
|||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@Configuration |
|||
public class TomcatConfig { |
|||
|
|||
|
|||
@Bean |
|||
public ServletWebServerFactory servletContainerFactory() { |
|||
|
|||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); |
|||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { |
|||
@Override |
|||
public void customize(Connector connector) { |
|||
((AbstractHttp11Protocol)connector.getProtocolHandler()).setMaxKeepAliveRequests(-1); |
|||
} |
|||
}); |
|||
factory.addContextCustomizers(new TomcatContextCustomizer() { |
|||
@Override |
|||
public void customize(Context context) { |
|||
context.setCookieProcessor(new LegacyCookieProcessor()); |
|||
} |
|||
}); |
|||
|
|||
return factory; |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.bzgame.server.luigi.api.filter; |
|||
|
|||
|
|||
import com.bzgame.server.luigi.api.RequestContext; |
|||
|
|||
import javax.servlet.*; |
|||
import javax.servlet.annotation.WebFilter; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import javax.servlet.http.HttpSession; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* @author nidaren |
|||
*/ |
|||
@WebFilter(filterName = "ContextFilter", urlPatterns = {"/api/*"}) |
|||
public class LoginFilter implements Filter { |
|||
|
|||
@Override |
|||
public void init(FilterConfig filterConfig) throws ServletException { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
|||
try { |
|||
HttpServletRequest httpRequest = (HttpServletRequest) request; |
|||
HttpSession session = httpRequest.getSession(); |
|||
Integer uid = (Integer) session.getAttribute("TODO"); |
|||
RequestContext.init(httpRequest, (HttpServletResponse) response, uid); |
|||
chain.doFilter(request, response); |
|||
} finally { |
|||
RequestContext.clear(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void destroy() { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,65 @@ |
|||
spring: |
|||
application: |
|||
name: luigi-api |
|||
aop: |
|||
auto: true |
|||
proxy-target-class: true |
|||
http: |
|||
encoding: |
|||
enabled: true |
|||
charset: UTF-8 |
|||
pid: |
|||
file: pid #pid文件名 |
|||
session: |
|||
redis: |
|||
namespace: sss:session |
|||
store-type: redis |
|||
redis: |
|||
host: 127.0.0.1 |
|||
port: 6379 |
|||
password: |
|||
maxTotal: 128 |
|||
poolMaxWaitMs: 50 |
|||
timeOutMs: 100 |
|||
|
|||
logging: |
|||
config: classpath:logback-spring.xml |
|||
|
|||
server: |
|||
port: 8001 |
|||
connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. |
|||
tomcat: |
|||
accept-count: 1024 # Maximum queue length for incoming connection requests when all possible request processing threads are in use. |
|||
max-connections: 256 # Maximum number of connections that the server will accept and process at any given time. |
|||
max-threads: 32 # Maximum amount of worker threads. |
|||
min-spare-threads: 4 # Minimum amount of worker threads. |
|||
accesslog: |
|||
enabled: false |
|||
directory: logs |
|||
prefix: tomcat_access_log |
|||
rotate: true |
|||
servlet: |
|||
session: |
|||
cookie: |
|||
domain: localhost |
|||
path: / |
|||
name: MARIO-JSESSIONID |
|||
max-age: 15d |
|||
timeout: 15d |
|||
|
|||
datasource: |
|||
mario: |
|||
type: com.zaxxer.hikari.HikariDataSource |
|||
jdbcUrl: jdbc:mysql://localhost:3306/mario?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&connectTimeout=300&socketTimeout=2000&serverTimezone=Asia/Shanghai&useAffectedRows=true |
|||
username: root |
|||
password: |
|||
connectionTimeout: 500 |
|||
maximumPoolSize: 32 |
|||
minimumIdle: 4 |
|||
idleTimeout: 600000 #This property controls the maximum amount of time that a connection is allowed to sit idle in the pool |
|||
maxLifetime: 3600000 #This property controls the maximum lifetime of a connection in the pool |
|||
connectionInitSql: "SET NAMES 'utf8mb4'" |
|||
|
|||
mybatis: |
|||
configuration: |
|||
map-underscore-to-camel-case: true #数据库字段下划线映射java对象属性用驼峰命名 |
@ -0,0 +1,33 @@ |
|||
spring: |
|||
application: |
|||
name: luigi-api |
|||
aop: |
|||
auto: true |
|||
proxy-target-class: true |
|||
http: |
|||
encoding: |
|||
enabled: true |
|||
charset: UTF-8 |
|||
pid: |
|||
file: pid #pid文件名 |
|||
|
|||
logging: |
|||
config: classpath:logback-spring.xml |
|||
|
|||
server: |
|||
port: 8001 |
|||
connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. |
|||
tomcat: |
|||
accept-count: 1024 # Maximum queue length for incoming connection requests when all possible request processing threads are in use. |
|||
max-connections: 256 # Maximum number of connections that the server will accept and process at any given time. |
|||
max-threads: 32 # Maximum amount of worker threads. |
|||
min-spare-threads: 4 # Minimum amount of worker threads. |
|||
accesslog: |
|||
enabled: false |
|||
directory: logs |
|||
prefix: tomcat_access_log |
|||
rotate: true |
|||
|
|||
mybatis: |
|||
configuration: |
|||
map-underscore-to-camel-case: true #数据库字段下划线映射java对象属性用驼峰命名 |
@ -0,0 +1,65 @@ |
|||
spring: |
|||
application: |
|||
name: luigi-api |
|||
aop: |
|||
auto: true |
|||
proxy-target-class: true |
|||
http: |
|||
encoding: |
|||
enabled: true |
|||
charset: UTF-8 |
|||
pid: |
|||
file: pid #pid文件名 |
|||
session: |
|||
redis: |
|||
namespace: sss:session |
|||
store-type: redis |
|||
redis: |
|||
host: 127.0.0.1 |
|||
port: 6379 |
|||
password: |
|||
maxTotal: 128 |
|||
poolMaxWaitMs: 50 |
|||
timeOutMs: 100 |
|||
|
|||
logging: |
|||
config: classpath:logback-spring.xml |
|||
|
|||
server: |
|||
port: 8001 |
|||
connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. |
|||
tomcat: |
|||
accept-count: 1024 # Maximum queue length for incoming connection requests when all possible request processing threads are in use. |
|||
max-connections: 256 # Maximum number of connections that the server will accept and process at any given time. |
|||
max-threads: 32 # Maximum amount of worker threads. |
|||
min-spare-threads: 4 # Minimum amount of worker threads. |
|||
accesslog: |
|||
enabled: false |
|||
directory: logs |
|||
prefix: tomcat_access_log |
|||
rotate: true |
|||
servlet: |
|||
session: |
|||
cookie: |
|||
domain: bzgames.cn |
|||
path: / |
|||
name: MARIO-JSESSIONID |
|||
max-age: 15d |
|||
timeout: 15d |
|||
|
|||
datasource: |
|||
mario: |
|||
type: com.zaxxer.hikari.HikariDataSource |
|||
jdbcUrl: jdbc:mysql://localhost:3306/mario?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&connectTimeout=300&socketTimeout=2000&serverTimezone=Asia/Shanghai&useAffectedRows=true |
|||
username: marioServer |
|||
password: YO@9A9e%0& |
|||
connectionTimeout: 500 |
|||
maximumPoolSize: 32 |
|||
minimumIdle: 4 |
|||
idleTimeout: 600000 #This property controls the maximum amount of time that a connection is allowed to sit idle in the pool |
|||
maxLifetime: 3600000 #This property controls the maximum lifetime of a connection in the pool |
|||
connectionInitSql: "SET NAMES 'utf8mb4'" |
|||
|
|||
mybatis: |
|||
configuration: |
|||
map-underscore-to-camel-case: true #数据库字段下划线映射java对象属性用驼峰命名 |
@ -0,0 +1,4 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="logconfig.xml"/> |
|||
</configuration> |
@ -0,0 +1,18 @@ |
|||
package com.bzgame.server.luigi; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@SpringBootApplication() |
|||
public class ApiTestApplication { |
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
|
|||
SpringApplication app = new SpringApplication(ApiTestApplication.class); |
|||
app.run(args); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.bzgame.server.luigi.api.test; |
|||
|
|||
import com.bzgame.server.luigi.ApiTestApplication; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.annotation.Commit; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@SpringBootTest(classes = ApiTestApplication.class) |
|||
@Commit |
|||
public class BaseTest { |
|||
} |
@ -0,0 +1,97 @@ |
|||
spring: |
|||
profiles: |
|||
active: default |
|||
aop: |
|||
auto: true |
|||
proxy-target-class: true |
|||
http: |
|||
encoding: |
|||
enabled: true |
|||
charset: utf-8 |
|||
pid: |
|||
file: pid #pid文件名 |
|||
|
|||
logging: |
|||
config: classpath:logback.xml |
|||
|
|||
datasource: |
|||
topic: |
|||
type: com.zaxxer.hikari.HikariDataSource |
|||
jdbcUrl: jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&connectTimeout=300&socketTimeout=2000&serverTimezone=Asia/Shanghai |
|||
username: xxx |
|||
password: xxx |
|||
connectionTimeout: 500 |
|||
maximumPoolSize: 32 |
|||
minimumIdle: 4 |
|||
idleTimeout: 600000 #This property controls the maximum amount of time that a connection is allowed to sit idle in the pool |
|||
maxLifetime: 3600000 #This property controls the maximum lifetime of a connection in the pool |
|||
|
|||
mybatis: |
|||
configuration: |
|||
map-underscore-to-camel-case: true #数据库字段下划线映射java对象属性用驼峰命名 |
|||
|
|||
redis: |
|||
maxTotal: 32 |
|||
poolMaxWaitMs: 1000 |
|||
timeOutMs: 500 |
|||
ip: 127.0.01 |
|||
port: 6379 |
|||
password: xxx |
|||
|
|||
server: |
|||
port: 8000 |
|||
connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. |
|||
tomcat: |
|||
accept-count: 1024 # Maximum queue length for incoming connection requests when all possible request processing threads are in use. |
|||
max-connections: 256 # Maximum number of connections that the server will accept and process at any given time. |
|||
max-threads: 32 # Maximum amount of worker threads. |
|||
min-spare-threads: 4 #Minimum amount of worker threads. |
|||
|
|||
eureka: |
|||
client: |
|||
register-with-eureka: true #向eureka注册 |
|||
fetchRegistry: true #拉取服务注册信息 |
|||
registry-fetch-interval-seconds: 30 #拉取服务注册信息频率 |
|||
instance-info-replication-interval-seconds: 30 #心跳频率 |
|||
service-url: |
|||
defaultZone: http:/localhost:8761/eureka/ #eureka地址.多个地址用逗号分隔 |
|||
instance: |
|||
prefer-ip-address: true #将ip注册到eureka |
|||
|
|||
feign: |
|||
hystrix: |
|||
enabled: true |
|||
client: |
|||
config: |
|||
#默认feign 客户端配置 |
|||
default: |
|||
connectTimeout: 5000 |
|||
readTimeout: 5000 |
|||
loggerLevel: BASIC |
|||
#特定服务的配置 |
|||
account-service: #fegin client name |
|||
connectTimeout: 1000 |
|||
readTimeout: 3000 |
|||
loggerLevel: BASIC |
|||
|
|||
hystrix: |
|||
#无法为每个feign client单独配置hystrix command属性https://github.com/spring-cloud/spring-cloud-netflix/issues/1864 |
|||
#采用default hystrix command 全局配置 |
|||
command: |
|||
default: |
|||
metrics: |
|||
rollingStats: |
|||
timeInMilliseconds: 10000 #滑动统计窗口 |
|||
circuitBreaker: |
|||
enabled: true #开启过载熔断 |
|||
requestVolumeThreshold: 1000 #滑动窗口内可触发按错误比例熔断的最小请求数 |
|||
errorThresholdPercentage: 50 #熔断触发错误比例 |
|||
sleepWindowInMilliseconds: 5000 #熔断时间 |
|||
execution: |
|||
isolation: |
|||
strategy: SEMAPHORE #采用线程池有性能问题,用SEMAPHORE |
|||
semaphore: |
|||
maxConcurrentRequests: 100 #信号量的上限 |
|||
thread: |
|||
timeoutInMilliseconds: 5000 #hystrix的超时时间 |
|||
|
@ -0,0 +1,3 @@ |
|||
spring: |
|||
application: |
|||
name: resource-api |
@ -0,0 +1,4 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="bcz/app/server/common/log/logconfig.xml"/> |
|||
</configuration> |
@ -0,0 +1,73 @@ |
|||
<?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"> |
|||
<parent> |
|||
<artifactId>luigi</artifactId> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>luigi-dao</artifactId> |
|||
|
|||
<properties> |
|||
<maven.compiler.source>17</maven.compiler.source> |
|||
<maven.compiler.target>17</maven.compiler.target> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-jdbc</artifactId> |
|||
<!--不用tomcat的数据库连接池--> |
|||
<exclusions> |
|||
<exclusion> |
|||
<groupId>org.apache.tomcat</groupId> |
|||
<artifactId>tomcat-jdbc</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.mybatis.spring.boot</groupId> |
|||
<artifactId>mybatis-spring-boot-starter</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.mybatis.generator</groupId> |
|||
<artifactId>mybatis-generator-maven-plugin</artifactId> |
|||
<version>1.3.7</version> |
|||
<configuration> |
|||
<configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile> |
|||
<verbose>true</verbose> |
|||
<overwrite>true</overwrite> |
|||
</configuration> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
<version>5.1.35</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<artifactId>common</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</dependency> |
|||
</dependencies> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
|
|||
</project> |
@ -0,0 +1,23 @@ |
|||
package com.bzgame.server.luigi.dao.config; |
|||
|
|||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Scope; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@Configuration |
|||
public class MybatisGeneralConfig { |
|||
|
|||
public static final String MBTS_CFG_NAME = "mybatisGeneralCfg"; |
|||
|
|||
@Bean(MBTS_CFG_NAME) |
|||
@ConfigurationProperties("mybatis.configuration") |
|||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) |
|||
public org.apache.ibatis.session.Configuration configuration() { |
|||
return new org.apache.ibatis.session.Configuration(); |
|||
} |
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.bzgame.server.luigi.dao.config; |
|||
|
|||
import com.zaxxer.hikari.HikariDataSource; |
|||
import org.apache.ibatis.session.SqlSessionFactory; |
|||
import org.mybatis.spring.SqlSessionFactoryBean; |
|||
import org.mybatis.spring.SqlSessionTemplate; |
|||
import org.mybatis.spring.annotation.MapperScan; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.boot.jdbc.DataSourceBuilder; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@Configuration |
|||
@MapperScan(basePackages = TopicDataSourceConfig.BASE_PACKAGE,sqlSessionFactoryRef = TopicDataSourceConfig.SSF_NAME,sqlSessionTemplateRef = TopicDataSourceConfig.SST_NAME) |
|||
public class TopicDataSourceConfig { |
|||
|
|||
|
|||
//TODO 修改配置常量名
|
|||
|
|||
public static final String DS_NAME = "topicDataSource"; |
|||
|
|||
public static final String TM_NAME = "topicTransactionManager"; |
|||
|
|||
public static final String SSF_NAME = "topicSqlSessionFactory"; |
|||
|
|||
public static final String SST_NAME = "topicSqlSessionTemplate"; |
|||
|
|||
public static final String DS_CFG_PREFIX = "datasource.topic"; |
|||
|
|||
public static final String BASE_PACKAGE = "bcz.app.server.luigi.dao.mapper"; |
|||
|
|||
@Bean(name = DS_NAME) |
|||
@ConfigurationProperties(DS_CFG_PREFIX) |
|||
public DataSource dataSource() { |
|||
return DataSourceBuilder.create().type(HikariDataSource.class).build(); |
|||
} |
|||
|
|||
@Bean(name = TM_NAME) |
|||
public DataSourceTransactionManager transactionManager(@Qualifier(DS_NAME) DataSource dataSource) { |
|||
return new DataSourceTransactionManager(dataSource); |
|||
} |
|||
|
|||
|
|||
@Bean(name = SSF_NAME) |
|||
public SqlSessionFactory sqlSessionFactory(@Qualifier(DS_NAME) DataSource dataSource, @Qualifier(MybatisGeneralConfig.MBTS_CFG_NAME) org.apache.ibatis.session.Configuration configuration) throws Exception { |
|||
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); |
|||
factoryBean.setConfiguration(configuration); |
|||
factoryBean.setDataSource(dataSource); |
|||
return factoryBean.getObject(); |
|||
} |
|||
|
|||
@Bean(name = SST_NAME) |
|||
public SqlSessionTemplate sqlSessionTemplate(@Qualifier(SSF_NAME) SqlSessionFactory sqlSessionFactory) { |
|||
return new SqlSessionTemplate(sqlSessionFactory); |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.bzgame.server.luigi.dao.domain; |
|||
|
|||
/** |
|||
* @author chenyang@baicizhan.com |
|||
* @date 2020/3/9 6:31 PM |
|||
*/ |
|||
public class DroolRules { |
|||
private long id; |
|||
private String rules; |
|||
|
|||
public long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getRules() { |
|||
return rules; |
|||
} |
|||
|
|||
public void setRules(String rules) { |
|||
this.rules = rules; |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.bzgame.server.luigi.dao.mapper; |
|||
|
|||
import com.bzgame.server.luigi.dao.domain.DroolRules; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
/** |
|||
* @author chenyang@baicizhan.com |
|||
* @date 2020/3/9 6:32 PM |
|||
*/ |
|||
public interface DroolRulesMapper { |
|||
@Select("SELECT *FROM drool_rules WHERE id=1") |
|||
DroolRules query(); |
|||
} |
@ -0,0 +1,24 @@ |
|||
#dao单元测试配置文件 |
|||
|
|||
spring: |
|||
profiles: |
|||
active: default |
|||
aop: |
|||
auto: true |
|||
proxy-target-class: true |
|||
|
|||
datasource: |
|||
topic: |
|||
type: com.zaxxer.hikari.HikariDataSource |
|||
jdbcUrl: jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&connectTimeout=1000&socketTimeout=3000&serverTimezone=Hongkong |
|||
username: xxx |
|||
password: xxx |
|||
connectionTimeout: 500 |
|||
maximumPoolSize: 5 |
|||
minimumIdle: 1 |
|||
idleTimeout: 600000 #This property controls the maximum amount of time that a connection is allowed to sit idle in the pool |
|||
maxLifetime: 3600000 #This property controls the maximum lifetime of a connection in the pool |
|||
|
|||
mybatis: |
|||
configuration: |
|||
map-underscore-to-camel-case: true #数据库字段下划线映射java对象属性用驼峰命名 |
@ -0,0 +1,54 @@ |
|||
<?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"> |
|||
<parent> |
|||
<artifactId>luigi</artifactId> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>luigi-service</artifactId> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-aop</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>redis.clients</groupId> |
|||
<artifactId>jedis</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.google.guava</groupId> |
|||
<artifactId>guava</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.fasterxml.jackson.core</groupId> |
|||
<artifactId>jackson-core</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.fasterxml.jackson.core</groupId> |
|||
<artifactId>jackson-databind</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.fasterxml.jackson.core</groupId> |
|||
<artifactId>jackson-annotations</artifactId> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
|
|||
</project> |
@ -0,0 +1,17 @@ |
|||
package com.bzgame.server.luigi; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@SpringBootApplication |
|||
public class ServiceTestApplication { |
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
|
|||
SpringApplication app = new SpringApplication(ServiceTestApplication.class); |
|||
app.run(args); |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.bzgame.server.luigi.service.test; |
|||
|
|||
import com.bzgame.server.luigi.ServiceTestApplication; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.annotation.Commit; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
|
|||
/** |
|||
* Created by cba/kit-backend on 2022-03-18 15:25:35 |
|||
*/ |
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@SpringBootTest(classes = ServiceTestApplication.class) |
|||
@Commit |
|||
public class BaseTest { |
|||
} |
@ -0,0 +1,25 @@ |
|||
#service单元测试配置文件 |
|||
|
|||
spring: |
|||
profiles: |
|||
active: default |
|||
aop: |
|||
auto: true |
|||
proxy-target-class: true |
|||
|
|||
datasource: |
|||
topic: |
|||
type: com.zaxxer.hikari.HikariDataSource |
|||
jdbcUrl: jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&connectTimeout=300&socketTimeout=2000&serverTimezone=Hongkong |
|||
username: xxx |
|||
password: xxx |
|||
connectionTimeout: 300 |
|||
maximumPoolSize: 5 |
|||
minimumIdle: 1 |
|||
idleTimeout: 600000 #This property controls the maximum amount of time that a connection is allowed to sit idle in the pool |
|||
maxLifetime: 3600000 #This property controls the maximum lifetime of a connection in the pool |
|||
|
|||
mybatis: |
|||
configuration: |
|||
map-underscore-to-camel-case: true #数据库字段下划线映射java对象属性用驼峰命名 |
|||
|
@ -0,0 +1,109 @@ |
|||
<?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.bzgame.server</groupId> |
|||
<artifactId>luigi</artifactId> |
|||
<packaging>pom</packaging> |
|||
<version>1.0-SNAPSHOT</version> |
|||
<modules> |
|||
<module>luigi-api</module> |
|||
<module>luigi-service</module> |
|||
<module>luigi-dao</module> |
|||
</modules> |
|||
|
|||
<properties> |
|||
<maven.compiler.source>17</maven.compiler.source> |
|||
<maven.compiler.target>17</maven.compiler.target> |
|||
</properties> |
|||
|
|||
<parent> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-parent</artifactId> |
|||
<version>2.6.2</version> |
|||
</parent> |
|||
|
|||
<dependencyManagement> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
<version>8.0.27</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.mybatis.spring.boot</groupId> |
|||
<artifactId>mybatis-spring-boot-starter</artifactId> |
|||
<version>1.3.2</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.google.code.gson</groupId> |
|||
<artifactId>gson</artifactId> |
|||
<version>2.8.9</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.bzgame.server</groupId> |
|||
<artifactId>common</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.squareup.okhttp3</groupId> |
|||
<artifactId>okhttp</artifactId> |
|||
<version>3.14.2</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.google.guava</groupId> |
|||
<artifactId>guava</artifactId> |
|||
<version>21.0</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 --> |
|||
<dependency> |
|||
<groupId>org.apache.commons</groupId> |
|||
<artifactId>commons-collections4</artifactId> |
|||
<version>4.1</version> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> |
|||
<dependency> |
|||
<groupId>org.apache.commons</groupId> |
|||
<artifactId>commons-lang3</artifactId> |
|||
<version>3.12.0</version> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/junit/junit --> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<version>4.13.2</version> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>redis.clients</groupId> |
|||
<artifactId>jedis</artifactId> |
|||
<version>2.9.0</version> |
|||
</dependency> |
|||
</dependencies> |
|||
</dependencyManagement> |
|||
<build> |
|||
<plugins> |
|||
<!--源码打包--> |
|||
<plugin> |
|||
<artifactId>maven-source-plugin</artifactId> |
|||
<version>3.2.1</version> |
|||
<configuration> |
|||
<attach>true</attach> |
|||
</configuration> |
|||
<executions> |
|||
<execution> |
|||
<phase>compile</phase><!--指定绑定的声明周期阶段--> |
|||
<goals> |
|||
<goal>jar</goal> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</project> |
@ -0,0 +1,34 @@ |
|||
#!/bin/bash |
|||
mode=`cat system.conf | awk -F = '{print$2}'` |
|||
|
|||
if [ -z "$mode" ]; then |
|||
echo "mode is not set" |
|||
exit 1 |
|||
fi |
|||
|
|||
project=`echo $mode | awk -F - '{print $1}'` |
|||
profile=`echo $mode | awk -F - '{print $2}'` |
|||
|
|||
if [ -z "$project" ]; then |
|||
echo "mode format is wrong" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ -z "$profile" ]; then |
|||
echo "mode format is wrong" |
|||
exit 1 |
|||
fi |
|||
version=1.0-SNAPSHOT |
|||
jar=luigi-$project-$version.jar |
|||
targetdir=luigi-$project/target |
|||
projectmem=256m |
|||
|
|||
if [ "$profile" = "prod" ] |
|||
then |
|||
projectmem=512m |
|||
fi |
|||
|
|||
rm -rf jar/* |
|||
cp $targetdir/$jar jar/ |
|||
|
|||
java -server -Xmx$projectmem -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -verbose:gc -Xlog:gc*:logs/gc.log:time,l,tg:filecount=7,filesize=16M -jar jar/$jar --spring.profiles.active=$profile > run.log 2>&1 |
@ -0,0 +1,14 @@ |
|||
#!/bin/bash |
|||
|
|||
|
|||
if [ -f pid ]; then |
|||
if kill `cat pid` ; then |
|||
echo 'kill process succeed' |
|||
else |
|||
echo 'kill process fail' |
|||
exit 1 |
|||
fi |
|||
else |
|||
echo 'pid file not exists' |
|||
exit 1 |
|||
fi |
Loading…
Reference in new issue