-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into develop-frontend
- Loading branch information
Showing
520 changed files
with
16,889 additions
and
3,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Rolling Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy-prod1: | ||
name: Deploy to Prod1 Instance | ||
runs-on: runner-prod1 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Prod1 instance deploy script | ||
run: | | ||
cd ~/deploy && ./deploy.sh | ||
check-prod1: | ||
name: Check Prod1 Instance | ||
runs-on: runner-prod1 | ||
needs: deploy-prod1 | ||
|
||
steps: | ||
- name: Wait for Prod1 instance to be ready | ||
run: sleep 30 | ||
|
||
- name: Health check for Prod1 instance | ||
run: | | ||
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/health) | ||
if [ $RESPONSE -ne 200 ]; then | ||
echo "Prod1 instance deployment failed." | ||
exit 1 | ||
fi | ||
echo "Prod1 instance is healthy." | ||
deploy-prod2: | ||
name: Deploy to Prod2 Instance | ||
runs-on: runner-prod2 | ||
needs: check-prod1 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Prod2 instance deploy script | ||
run: | | ||
cd ~/deploy && ./deploy.sh | ||
check-prod2: | ||
name: Check Prod2 Instance | ||
runs-on: runner-prod2 | ||
needs: deploy-prod2 | ||
|
||
steps: | ||
- name: Wait for Prod2 instance to be ready | ||
run: sleep 30 | ||
|
||
- name: Health check for Prod2 instance | ||
run: | | ||
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/health) | ||
if [ $RESPONSE -ne 200 ]; then | ||
echo "Prod2 instance deployment failed." | ||
exit 1 | ||
fi | ||
echo "Prod2 instance is healthy." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +0,0 @@ | ||
name: cd-prod | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
deploy: | ||
runs-on: prod | ||
|
||
steps: | ||
- name: deploy | ||
run: | | ||
cd ~/deploy && ./deploy.sh | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/mouda/backend/aop/logging/ExceptRequestLogging.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package mouda.backend.aop.logging; | ||
|
||
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 ExceptRequestLogging { | ||
|
||
} |
106 changes: 106 additions & 0 deletions
106
backend/src/main/java/mouda/backend/aop/logging/RequestLoggingAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package mouda.backend.aop.logging; | ||
|
||
import static java.util.stream.Collectors.*; | ||
|
||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Parameter; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
import org.aspectj.lang.annotation.Pointcut; | ||
import org.aspectj.lang.reflect.MethodSignature; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.extern.slf4j.Slf4j; | ||
import mouda.backend.darakbangmember.domain.DarakbangMember; | ||
import mouda.backend.member.domain.Member; | ||
|
||
@Aspect | ||
@Component | ||
@Slf4j | ||
public class RequestLoggingAspect { | ||
|
||
@Pointcut("execution(* mouda.backend..controller.*Controller.*(..))") | ||
public void allController() { | ||
} | ||
|
||
@Before("allController()") | ||
public void logController(JoinPoint joinPoint) { | ||
HttpServletRequest request = getHttpServletRequest(); | ||
|
||
MethodSignature signature = (MethodSignature)joinPoint.getSignature(); | ||
Method method = signature.getMethod(); | ||
if (method.isAnnotationPresent(ExceptRequestLogging.class)) { | ||
return; | ||
} | ||
|
||
String uri = request.getRequestURI(); | ||
String httpMethod = request.getMethod(); | ||
String queryParameters = getQueryParameters(request); | ||
String body = getBody(joinPoint); | ||
|
||
String memberInfo = getMemberInfo(joinPoint); | ||
|
||
StringBuilder stringBuilder = new StringBuilder(); | ||
stringBuilder.append(String.format("Request : %s %s", httpMethod, uri)); | ||
if (memberInfo != null) { | ||
stringBuilder.append(String.format(", member : %s", memberInfo)); | ||
} | ||
if (body != null) { | ||
stringBuilder.append(String.format(", body : %s", body)); | ||
} | ||
if (queryParameters != null) { | ||
stringBuilder.append(String.format(", parameters : %s", queryParameters)); | ||
} | ||
log.info(stringBuilder.toString()); | ||
} | ||
|
||
private String getMemberInfo(JoinPoint joinPoint) { | ||
for (Object arg : joinPoint.getArgs()) { | ||
if (arg instanceof Member) { | ||
return "Member ID = " + ((Member)arg).getId(); | ||
} | ||
if (arg instanceof DarakbangMember) { | ||
return "DarakbangMember ID = " + ((DarakbangMember)arg).getId(); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private HttpServletRequest getHttpServletRequest() { | ||
ServletRequestAttributes requestAttributes = (ServletRequestAttributes)RequestContextHolder.currentRequestAttributes(); | ||
return requestAttributes.getRequest(); | ||
} | ||
|
||
private String getQueryParameters(HttpServletRequest request) { | ||
String queryParameters = request.getParameterMap() | ||
.entrySet() | ||
.stream() | ||
.map(entry -> "%s = %s".formatted(entry.getKey(), entry.getValue()[0])) | ||
.collect(joining(", ")); | ||
|
||
if (queryParameters.isEmpty()) { | ||
return null; | ||
} | ||
return queryParameters; | ||
} | ||
|
||
private String getBody(JoinPoint joinPoint) { | ||
MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature(); | ||
Parameter[] parameters = methodSignature.getMethod().getParameters(); | ||
Object[] args = joinPoint.getArgs(); | ||
for (int i = 0; i < parameters.length; i++) { | ||
Parameter param = parameters[i]; | ||
Object arg = args[i]; | ||
if (param.isAnnotationPresent(RequestBody.class)) { | ||
return arg.toString(); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.