-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from boostcampwm-2022/Redis/Scheduler
Redis/scheduler
- Loading branch information
Showing
16 changed files
with
3,486 additions
and
23 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,26 @@ | ||
name: CI/CD on Redis | ||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy-client: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: deploy redis scheduler | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.REDIS }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
port: ${{ secrets.REDIS_PORT }} | ||
script: | | ||
export NVM_DIR=~/.nvm | ||
source ~/.nvm/nvm.sh | ||
npm --help | ||
cd /home/web28-Boostform | ||
git pull | ||
cd /root/boostForm/redis | ||
npm i | ||
pm2 reload all |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
node_modules | ||
.env |
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,6 @@ | ||
import mongoose from "mongoose"; | ||
import { FormSchema } from "./Form.Schema.js"; | ||
|
||
const Form = mongoose.model("Form", FormSchema); | ||
|
||
export default Form; |
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,78 @@ | ||
import mongoose from "mongoose"; | ||
|
||
const QuestionSchema = new mongoose.Schema({ | ||
question_id: { | ||
type: Number, | ||
required: true, | ||
}, | ||
page: { | ||
type: Number, | ||
}, | ||
type: { | ||
type: String, | ||
required: true, | ||
enum: ["checkbox", "multiple", "paragraph"], | ||
}, | ||
title: { | ||
type: String, | ||
default: "제목 없음", | ||
}, | ||
option: { | ||
type: [String], | ||
}, | ||
essential: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
etc_added: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}); | ||
|
||
const FormSchema = new mongoose.Schema( | ||
{ | ||
user_id: { | ||
type: Number, | ||
required: true, | ||
}, | ||
title: { | ||
type: String, | ||
default: "제목 없음", | ||
}, | ||
description: { | ||
type: String, | ||
}, | ||
category: { | ||
type: String, | ||
}, | ||
question_list: { | ||
type: [QuestionSchema], | ||
}, | ||
accept_response: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
on_board: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
login_required: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
response_modifiable: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
response_count: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
}, | ||
{ | ||
timestamps: true, | ||
} | ||
); | ||
|
||
export { QuestionSchema, FormSchema }; |
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,6 @@ | ||
import mongoose from "mongoose"; | ||
import { ResponseSchema } from "./Response.Schema.js"; | ||
|
||
const FormResponse = mongoose.model("Response", ResponseSchema); | ||
|
||
export default FormResponse; |
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,25 @@ | ||
import mongoose from "mongoose"; | ||
|
||
const AnswerSchema = new mongoose.Schema({ | ||
question_id: { | ||
type: Number, | ||
}, | ||
answer: { | ||
type: [String], | ||
}, | ||
}); | ||
|
||
const ResponseSchema = new mongoose.Schema({ | ||
user_id: { | ||
type: Number, | ||
}, | ||
form_id: { | ||
type: String, | ||
index: true, | ||
}, | ||
answer_list: { | ||
type: [AnswerSchema], | ||
}, | ||
}); | ||
|
||
export { AnswerSchema, ResponseSchema }; |
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
File renamed without changes.
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,38 @@ | ||
import * as dotenv from "dotenv"; | ||
import mongoose from "mongoose"; | ||
import * as redis from "redis"; | ||
|
||
dotenv.config(); | ||
|
||
// MongoDB 연결 | ||
function connectDB() { | ||
mongoose.connect( | ||
`mongodb+srv://${process.env.MONGODB_ID}:${process.env.MONGODB_PASSWORD}@cluster0.a7vmgdw.mongodb.net/database0?`, | ||
(err) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log("mongoDB is connected..."); | ||
} | ||
} | ||
); | ||
} | ||
|
||
connectDB(); | ||
|
||
// redis 연결 | ||
const redisClient = redis.createClient({ | ||
url: `redis://@${process.env.REDIS_HOST}:${process.env.REDIS_PORT}/0`, | ||
legacyMode: true, | ||
}); | ||
|
||
redisClient.on("connect", () => { | ||
console.info("Redis connected!"); | ||
}); | ||
redisClient.on("error", (err) => { | ||
console.error("Redis Client Error", err); | ||
}); | ||
|
||
redisClient.connect(); | ||
|
||
export const redisCli = redisClient.v4; |
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,11 @@ | ||
import ResponseSaveScheduler from "./Scheduler/ResponseSaveScheduler.js"; | ||
import CountIncreaseScheduler from "./Scheduler/CountIncreaseScheduler.js"; | ||
import ResponseUpdateScheduler from "./Scheduler/ResponseUpdateScheduler.js"; | ||
|
||
try { | ||
ResponseSaveScheduler.init(); | ||
CountIncreaseScheduler.init(); | ||
ResponseUpdateScheduler.init(); | ||
} catch (err) { | ||
console.log(err); | ||
} |
Oops, something went wrong.