Skip to content

Commit

Permalink
[mod] 서버 계정 이전으로 인한 환경변수 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hyejungg committed Jun 6, 2023
1 parent 754d219 commit acea366
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/developDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
echo DB_DEV_PASSWORD=${{ secrets.DB_DEV_PASSWORD }} >> .env
echo DB_DEV_NAME=${{ secrets.DB_DEV_NAME }} >> .env
echo DB_PORT=${{ secrets.DB_PORT }} >> .env
echo REDIS_HOST=${{ secrets.REDIS_HOST }} >> .env
echo REDIS_HOST=${{ secrets.REDIS_DEV_HOST }} >> .env
echo REDIS_PORT=${{ secrets.REDIS_PORT }} >> .env
echo REDIS_DEV_PASSWORD=${{ secrets.REDIS_DEV_PASSWORD }} >> .env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/productDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ jobs:
aws s3 cp \
--recursive \
--region ap-northeast-2 \
dist s3://wishboard-server-build
dist s3://wishboard-prod-build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typings/
# dotenv environment variables file
.env
.env.test
.env.backup

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
35 changes: 23 additions & 12 deletions src/config/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@ const Redis = require('ioredis');
const logger = require('./winston');
require('dotenv').config({ path: '../.env' });

const REDIS_HOST = process.env.REDIS_HOST;
const REDIS_PORT = process.env.REDIS_PORT;
const nodeEnv = process.env.NODE_ENV;
let redisHost;
let redisPort;

let redisPassword = process.env.REDIS_DEV_PASSWORD;
const nodeEnv = process.env.NODE_ENV;
if (nodeEnv === 'production') {
redisPassword = process.env.REDIS_PASSWORD;
redisHost = process.env.REDIS_HOST;
redisPort = process.env.REDIS_PORT;
} else {
redisHost = process.env.REDIS_DEV_HOST;
redisPort = process.env.REDIS_DEV_PORT;
}

let redis;

const redisConnect = () => {
try {
redis = new Redis({
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
password: redisPassword,
showFriendlyErrorStack: true,
});
logger.info(`redis(${REDIS_HOST}:${REDIS_PORT}) connect success!`);
if (nodeEnv === 'production') {
redis = new Redis({
host: redisHost,
port: redisPort,
showFriendlyErrorStack: true,
});
} else {
redis = new Redis({
host: redisHost,
port: redisPort,
password: redisPassword,
showFriendlyErrorStack: true,
});
}
logger.info(`redis ${nodeEnv} connect success!`);
} catch (err) {
logger.error(err.message);
process.exit(1);
Expand Down

0 comments on commit acea366

Please sign in to comment.