Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Local, Prod 환경 분리 close #72 #73

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ out/
ChaChaKeyStore.p12

# Firebase
letmeknow-bdaef-firebase-adminsdk-ogpdk-7f7f7325ab.json
letmeknow-bdaef-firebase-adminsdk-ogpdk-7f7f7325ab.json

# logs
logs/
51 changes: 26 additions & 25 deletions src/main/java/com/letmeknow/quartz/schedule/QuartzConfig.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.letmeknow.quartz.schedule;

import com.letmeknow.analyser.Analyser;
import com.letmeknow.enumstorage.SpringProfile;
import com.letmeknow.quartz.AutoWiringSpringBeanJobFactory;
import org.quartz.DateBuilder;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import lombok.RequiredArgsConstructor;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
Expand All @@ -25,11 +24,13 @@
import static org.quartz.TriggerBuilder.newTrigger;

@Configuration
@RequiredArgsConstructor
public class QuartzConfig {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private PlatformTransactionManager transactionManager;
private final ApplicationContext applicationContext;
private final PlatformTransactionManager transactionManager;

@Value("${spring.profiles.active}")
private String activeProfile;

@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
Expand Down Expand Up @@ -79,26 +80,26 @@ public JobDetail jobDetail() {

@Bean
public Trigger trigger() {
// Trigger the job to run now, and then repeat every 40 seconds
// return newTrigger()
// .withIdentity("trigger1", "group1")
// .forJob("job1", "group1")
// .build();
return newTrigger()
TriggerBuilder<Trigger> triggerTriggerBuilder = newTrigger();
triggerTriggerBuilder
.withIdentity("trigger1", "group1")
.forJob(jobDetail())

// // 매일 10시 30분부터 17시 30분까지 1시간마다 실행
// .startNow()
// .withSchedule(cronSchedule("0 30 10-17/1 * * ?"))

////////////////////////////////////////////////////////////////////////////////////////////////////////////
.forJob(jobDetail());

// Local Profile은 10초 후에 1번만 실행
if (activeProfile.equals(SpringProfile.LOCAL.getProfile())) {
triggerTriggerBuilder
.startAt(DateBuilder.futureDate(10, DateBuilder.IntervalUnit.SECOND)) // 10초 후에 실행
.withSchedule(simpleSchedule()
.withRepeatCount(0)) // 1번만 실행

.build();
.withSchedule(simpleSchedule()
.withRepeatCount(0)); // 1번만 실행
}
// Prod Profile은 매일 10시 30분부터 17시 30분까지 1시간마다 실행
else if (activeProfile.equals(SpringProfile.PROD.getProfile())) {
triggerTriggerBuilder
.startNow()
.withSchedule(cronSchedule("0 30 10-17/1 * * ?"));
}

return triggerTriggerBuilder.build();
}

// @Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public interface BoardRepository extends JpaRepository<Board, Long> {
@Query(
value = "SELECT b.BOARD_ID as id, b.board_name as boardName, b.board_view_url as boardViewUrl, IF(COUNT(s.SUBSCRIPTION_ID) > 0, 'TRUE', 'FALSE') as isSubscribed\n" +
"FROM Board b\n" +
"FROM board b\n" +
"LEFT JOIN subscription as s ON b.board_id = s.board_id\n" +
"AND s.member_id = :memberId\n" +
"WHERE b.college_id = :collegeId\n" +
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ spring:
hibernate:
ddl-auto: ${JPA.DDL_AUTO}

logging:
level:
org:
hibernate.SQL: trace


# JWT
jwt:
token:
access:
expiration: 86_400_000 # 1일

logging:
level:
p6spy: DEBUG

decorator:
datasource:
p6spy:
enable-logging: true
4 changes: 4 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ jwt:
token:
access:
expiration: 300000 # 5분

logging:
level:
p6spy: INFO
15 changes: 2 additions & 13 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ spring:
# show_sql: true
# format_sql: true
# dialect: org.hibernate.dialect.MySQL5InnoDBDialect
logging.level:
org.hibernate.SQL: debug
open-in-view: false
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
properties:
hibernate:
default_batch_fetch_size: 100
logging:
level:
org:
hibernate:
SQL: trace

security:
oauth2:
client:
Expand Down Expand Up @@ -94,18 +88,13 @@ server:
# p6spy
logging:
file:
path: /Users/mac/Desktop/letmeknow/log
path: ./logs
level:
root: info
p6spy: debug
logback:
rollingpolicy:
max-file-size: 50MB
max-history: 10
decorator:
datasource:
p6spy:
enable-logging: true
# p6spy

# cors
Expand Down