사용하지않는 dockerfile, jenkinsfile 제거
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -1,20 +0,0 @@
|
||||
FROM openjdk:17
|
||||
|
||||
#인수 설정
|
||||
ARG JAR_FILE=build/libs/CaliverseAdminAPI.jar
|
||||
|
||||
#환경 변수
|
||||
#ENV ENVIRONMENT=${ENVIRONMENT}
|
||||
#
|
||||
#RUN if [ "$ENVIRONMENT" = "stage" ] ; then \
|
||||
# JAR_FILE=build/libs/CaliverseAdminAPI-stage.jar ; \
|
||||
# elif [ "$ENVIRONMENT" = "live" ] ; then \
|
||||
# JAR_FILE=build/libs/CaliverseAdminAPI-live.jar ; \
|
||||
# else \
|
||||
# JAR_FILE=build/libs/CaliverseAdminAPI.jar ; \
|
||||
# fi
|
||||
|
||||
COPY ${JAR_FILE} admintool.jar
|
||||
#메모리 최소 2기가 최대 4기가
|
||||
ENV JAVA_OPTS="-Xms2g -Xmx4g"
|
||||
ENTRYPOINT ["java","-jar","/admintool.jar"]
|
||||
100
Jenkinsfile
vendored
100
Jenkinsfile
vendored
@@ -1,100 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
DOCKER_IMAGE = 'caliverse/admintool-back'
|
||||
DOCKER_TAG = '1.0.0'
|
||||
DOCKER_TAG_PRE = '1.0.0'
|
||||
FILE_NAME = 'admintool_back.tar'
|
||||
DOCKER_NAME = 'admintool-back'
|
||||
DOCKER_PORT = '23450'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Gradle Build') {
|
||||
steps {
|
||||
script {
|
||||
sh 'chmod +x gradlew' //gradle 권한 설정
|
||||
sh './gradlew clean build -x test -Pprofile=stage' //추후
|
||||
// sh './gradlew clean build -x test' //빌드 test는 하지않는다
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker Image Build') {
|
||||
steps {
|
||||
script {
|
||||
sh 'docker rmi $DOCKER_IMAGE:$DOCKER_TAG_PRE || true' //이전 이미지 삭제
|
||||
sh 'rm $FILE_NAME || true' //이전 .tar 파일 삭제
|
||||
sh 'docker build -t $DOCKER_IMAGE:$DOCKER_TAG .'
|
||||
echo 'Docker Image Create'
|
||||
sh 'docker save -o $FILE_NAME $DOCKER_IMAGE:$DOCKER_TAG'
|
||||
echo 'Docker Image > .tar File Create'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('SSH Tunneling') {
|
||||
steps {
|
||||
script {
|
||||
sh 'sudo lsof -ti @127.30.148.164:2211 | xargs -r sudo kill -9; sudo ssh -f -N -L 127.30.148.164:2211:172.30.148.164:2211 ubuntu@52.32.111.3 -p 2211 -i /home/admintool/USWest2-KeyPair.pem -o StrictHostKeyChecking=no'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Transfer Docker Image') {
|
||||
steps {
|
||||
// aws .tar transfer
|
||||
sshPublisher(
|
||||
publishers: [
|
||||
sshPublisherDesc(
|
||||
configName: 'stage-backend',
|
||||
transfers: [
|
||||
sshTransfer(
|
||||
sourceFiles: "${FILE_NAME}",
|
||||
remoteDirectory: '',
|
||||
execCommand: """
|
||||
echo '.tar Transfer Complete'
|
||||
""",
|
||||
execTimeout: 120000
|
||||
)
|
||||
],
|
||||
usePromotionTimestamp: false,
|
||||
verbose: true
|
||||
)
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
stage('Deploy to Remote'){
|
||||
steps{
|
||||
// aws command
|
||||
sshPublisher(
|
||||
publishers: [
|
||||
sshPublisherDesc(
|
||||
configName: 'stage-backend',
|
||||
transfers: [
|
||||
sshTransfer(
|
||||
execCommand: """
|
||||
docker stop ${DOCKER_NAME} || true &&
|
||||
docker rm ${DOCKER_NAME} || true &&
|
||||
docker rmi ${DOCKER_IMAGE}:${DOCKER_TAG_PRE} || true &&
|
||||
docker load -i ${FILE_NAME} &&
|
||||
docker run -d \
|
||||
-p ${DOCKER_PORT}:${DOCKER_PORT} \
|
||||
--name ${DOCKER_NAME} \
|
||||
--restart=always \
|
||||
-e TZ=\${TZ:-Asia/Seoul} \
|
||||
-v ./admintool/log:/logs \
|
||||
${DOCKER_IMAGE}:${DOCKER_TAG} &&
|
||||
rm ${FILE_NAME}
|
||||
""",
|
||||
execTimeout: 120000
|
||||
)
|
||||
],
|
||||
usePromotionTimestamp: false,
|
||||
verbose: true
|
||||
)
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import com.caliverse.admin.domain.RabbitMq.MessageHandlerService;
|
||||
import com.caliverse.admin.domain.RabbitMq.message.IntervalType;
|
||||
import com.caliverse.admin.domain.dao.admin.RankMapper;
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.ERankingType;
|
||||
import com.caliverse.admin.domain.entity.RankingSchedule;
|
||||
import com.caliverse.admin.domain.entity.WorldEvent;
|
||||
import com.caliverse.admin.domain.entity.log.LogAction;
|
||||
import com.caliverse.admin.domain.request.RankRequest;
|
||||
import com.caliverse.admin.domain.request.WorldEventRequest;
|
||||
import com.caliverse.admin.domain.response.RankResponse;
|
||||
import com.caliverse.admin.domain.response.RankResponse;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbBattleEventService;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.*;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.RankDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.RankerSnapshotDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.RankingSnapshotDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.EScoreType;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbRankService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.annotation.BusinessProcess;
|
||||
import com.caliverse.admin.global.common.annotation.RequestLog;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
@@ -19,18 +23,14 @@ import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.mongodb.service.MysqlHistoryLogService;
|
||||
import com.caliverse.admin.redis.service.RedisUserInfoService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -41,6 +41,9 @@ public class RankService {
|
||||
private final MessageHandlerService messageHandlerService;
|
||||
private final RedisUserInfoService redisUserInfoService;
|
||||
private final DynamodbRankService dynamodbRankService;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final UserGameSessionService userGameSessionService;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getList(Map requestParam){
|
||||
@@ -64,6 +67,21 @@ public class RankService {
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getList(){
|
||||
|
||||
List<RankingSchedule> list = rankMapper.getRankingScheduleSimpleList();
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.rankingScheduleList(list)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getDetail(Long id){
|
||||
RankingSchedule rankingSchedule = rankMapper.getRankingScheduleDetail(id);
|
||||
@@ -77,12 +95,152 @@ public class RankService {
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getRankingSnapshotList(String guid){
|
||||
List<RankingSnapshotDoc> rankDocList = dynamodbRankService.getRankingSnapshotList(guid);
|
||||
|
||||
List<RankResponse.RankingSnapshotInfo> rankingInfoList = rankDocList.stream()
|
||||
.map(doc -> {
|
||||
RankingSnapshotAttrib attrib = doc.getAttribValue();
|
||||
|
||||
return RankResponse.RankingSnapshotInfo.builder()
|
||||
.rankingGuid(guid)
|
||||
.snapshotIndex(attrib.getSnapshotIndex())
|
||||
.snapshotTime(attrib.getSnapshotTime())
|
||||
.build();
|
||||
}).toList();
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.rankingSnapshotList(rankingInfoList)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getRankerList(String guid, Integer snapshotIndex){
|
||||
List<RankerSnapshotDoc> rankDocList = dynamodbRankService.getRankerSnapshotList(guid, snapshotIndex);
|
||||
|
||||
List<RankResponse.UserRankerInfo> userRankerInfoList = rankDocList.stream()
|
||||
.sorted(Comparator.comparing(doc -> doc.getAttribValue().getRankNum()))
|
||||
.map(doc -> {
|
||||
RankerSnapshotAttrib attrib = doc.getAttribValue();
|
||||
|
||||
Integer rankNum = attrib.getRankNum() == null ? 0 : attrib.getRankNum();
|
||||
|
||||
String userGuid = attrib.getRankerGuid();
|
||||
String nickname = dynamodbUserService.getGuidByName(userGuid);
|
||||
String accountId = dynamodbUserService.getGuidByAccountId(userGuid);
|
||||
|
||||
return RankResponse.UserRankerInfo.builder()
|
||||
.rank(rankNum)
|
||||
.score(attrib.getScore())
|
||||
.scoreType(attrib.getScoreType())
|
||||
.userGuid(userGuid)
|
||||
.nickname(nickname)
|
||||
.accountId(accountId)
|
||||
.rankingGuid(guid)
|
||||
.build();
|
||||
})
|
||||
.toList();
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.rankerList(userRankerInfoList)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getRankList(String guid){
|
||||
List<RankDoc> rankDocList = dynamodbRankService.getRankList(guid);
|
||||
|
||||
List<RankResponse.UserRankerInfo> userRankerInfoList = rankDocList.stream()
|
||||
.sorted(Comparator.comparing(doc -> doc.getAttribValue().getRankNum()))
|
||||
.map(doc -> {
|
||||
RankAttrib attrib = doc.getAttribValue();
|
||||
|
||||
String userGuid = attrib.getRankerGuid();
|
||||
String nickname = dynamodbUserService.getGuidByName(userGuid);
|
||||
String accountId = dynamodbUserService.getGuidByAccountId(userGuid);
|
||||
|
||||
return RankResponse.UserRankerInfo.builder()
|
||||
.rank(attrib.getRankNum())
|
||||
.score(attrib.getScore())
|
||||
.scoreType(attrib.getScoreType())
|
||||
.userGuid(userGuid)
|
||||
.nickname(nickname)
|
||||
.accountId(accountId)
|
||||
.rankingGuid(guid)
|
||||
.build();
|
||||
}).toList();
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.rankerList(userRankerInfoList)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getRankingInfo(String userGuid){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("status", RankingSchedule.EVENT_STATUS.RUNNING.toString());
|
||||
|
||||
List<RankingSchedule> list = rankMapper.getRankingScheduleList(param);
|
||||
|
||||
RankResponse.UserRankingInfo info = new RankResponse.UserRankingInfo();
|
||||
List<RankResponse.UserRankingInfo.RankerItem> rankerItems = new ArrayList<>();
|
||||
list.forEach(data -> {
|
||||
String rankingGuid = data.getGuid();
|
||||
ERankingType rankingType = ERankingType.fromMetaId(data.getMetaId());
|
||||
RankerAttrib attrib = dynamodbRankService.getRanker(rankingGuid, userGuid);
|
||||
if(attrib == null) return;
|
||||
|
||||
EScoreType scoreType = attrib.getScoreType();
|
||||
Integer score = attrib.getScore();
|
||||
|
||||
RankResponse.UserRankingInfo.RankerItem item = RankResponse.UserRankingInfo.RankerItem.builder()
|
||||
.rankingType(rankingType)
|
||||
.score(score)
|
||||
.scoreType(scoreType)
|
||||
.guid(data.getGuid())
|
||||
.build();
|
||||
|
||||
rankerItems.add(item);
|
||||
});
|
||||
info.setRankingItems(rankerItems);
|
||||
info.setUserGuid(userGuid);
|
||||
|
||||
return RankResponse.builder()
|
||||
.resultData(
|
||||
RankResponse.ResultData.builder()
|
||||
.userRankingInfo(info)
|
||||
.build()
|
||||
)
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_SCHEDULE)
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
@RequestLog
|
||||
public RankResponse postRankingSchedule(RankRequest rankRequest){
|
||||
rankRequest.setCreateBy(CommonUtils.getAdmin().getId());
|
||||
|
||||
int chk = rankMapper.checkOverlap(rankRequest);
|
||||
if(chk > 0){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_SCHEDULE_DUPLICATE.getMessage());
|
||||
}
|
||||
|
||||
rankRequest.setGuid(CommonUtils.getSimpleCreateGuId());
|
||||
|
||||
rankMapper.postRankingSchedule(rankRequest);
|
||||
@@ -101,7 +259,7 @@ public class RankService {
|
||||
|
||||
dynamodbRankService.insertRankingSchedule(rankRequest);
|
||||
|
||||
notifyGameServers("postRankingSchedule", null);
|
||||
notifyGameServers("postRankingSchedule", "",null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
@@ -120,6 +278,11 @@ public class RankService {
|
||||
rankRequest.setUpdateBy(CommonUtils.getAdmin().getId());
|
||||
rankRequest.setUpdateDt(LocalDateTime.now());
|
||||
|
||||
int chk = rankMapper.checkOverlap(rankRequest);
|
||||
if(chk > 0){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_SCHEDULE_DUPLICATE.getMessage());
|
||||
}
|
||||
|
||||
Long schedule_id = rankRequest.getId();
|
||||
RankingSchedule before_info = rankMapper.getRankingScheduleDetail(schedule_id);
|
||||
|
||||
@@ -135,7 +298,86 @@ public class RankService {
|
||||
|
||||
dynamodbRankService.updateRankingSchedule(rankRequest);
|
||||
|
||||
notifyGameServers("updateRankingSchedule", null);
|
||||
notifyGameServers("updateRankingSchedule", "", null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.UPDATE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKER_INFO)
|
||||
@RequestLog
|
||||
public RankResponse updateRankerInfo(RankRequest rankRequest) {
|
||||
String adminUser = CommonUtils.getAdmin().getEmail();
|
||||
|
||||
String userGuid = rankRequest.getUserGuid();
|
||||
String rankingGuid = rankRequest.getGuid();
|
||||
|
||||
if(userGuid == null || userGuid.isEmpty() || rankingGuid == null || rankingGuid.isEmpty() ){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.WARNING_GUID_CHECK.getMessage());
|
||||
}
|
||||
|
||||
userGameSessionService.kickUserSession(userGuid, String.format("admin %s Ranker Info Update kick", adminUser));
|
||||
|
||||
dynamodbRankService.updateRanker(rankRequest);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.UPDATE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_UPDATE)
|
||||
@RequestLog
|
||||
public RankResponse updateRanking(String guid) {
|
||||
if(redisUserInfoService.getAllServerList().isEmpty()){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
notifyGameServers("updateRanking", guid, null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.UPDATE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_UPDATE)
|
||||
@RequestLog
|
||||
public RankResponse updateSnapshot(String guid) {
|
||||
if(redisUserInfoService.getAllServerList().isEmpty()){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
notifyGameServers("updateSnapshot", guid, null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.UPDATE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_UPDATE)
|
||||
@RequestLog
|
||||
public RankResponse updateRankingInit(String guid) {
|
||||
if(redisUserInfoService.getAllServerList().isEmpty()){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
notifyGameServers("updateRankingInit", guid, null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
@@ -175,7 +417,7 @@ public class RankService {
|
||||
|
||||
dynamodbRankService.deleteRankingSchedule(info);
|
||||
|
||||
notifyGameServers("deleteRankingSchedule", null);
|
||||
notifyGameServers("deleteRankingSchedule", "", null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
@@ -186,7 +428,7 @@ public class RankService {
|
||||
.build();
|
||||
}
|
||||
|
||||
private void notifyGameServers(String methodName, Runnable rollbackFunction) {
|
||||
private void notifyGameServers(String methodName, String guid, Runnable rollbackFunction) {
|
||||
// 운영DB 데이터 추가됐다고 게임서버 알림
|
||||
List<String> serverList = redisUserInfoService.getAllServerList();
|
||||
if(serverList.isEmpty()){
|
||||
@@ -198,7 +440,16 @@ public class RankService {
|
||||
}
|
||||
|
||||
try{
|
||||
serverList.forEach(messageHandlerService::sendRankingScheduleMessage);
|
||||
switch (methodName) {
|
||||
case "updateRanking" ->
|
||||
serverList.forEach(server -> messageHandlerService.sendRankingUpdateMessage(server, guid, IntervalType.IntervalType_Refresh));
|
||||
case "updateSnapshot" ->
|
||||
serverList.forEach(server -> messageHandlerService.sendRankingUpdateMessage(server, guid, IntervalType.IntervalType_Snapshot));
|
||||
case "updateRankingInit" ->
|
||||
serverList.forEach(server -> messageHandlerService.sendRankingUpdateMessage(server, guid, IntervalType.IntervalType_Initialization));
|
||||
default -> serverList.forEach(messageHandlerService::sendRankingScheduleMessage);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("{} messageHandlerService error: {}", methodName, e.getMessage(), e);
|
||||
if (rollbackFunction != null) {
|
||||
|
||||
Reference in New Issue
Block a user