Skip to content

Commit 90a7d17

Browse files
committed
feat: 서버 잠들기 방지 코드 작성
1 parent 4319fdf commit 90a7d17

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

app.js

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import 'express-async-errors';
33
import cors from 'cors';
44
import morgan from 'morgan';
55
import helmet from 'helmet';
6+
import cron from 'node-cron';
7+
import http from 'http';
68
import authRouter from './routers/auth.js';
79
import waffleCardRouter from './routers/waffleCard.js';
810
import commentRouter from './routers/comment.js';
@@ -44,3 +46,9 @@ connectDB().then(() => {
4446
console.log(`Server is started... ${new Date()}`);
4547
app.listen(config.port);
4648
});
49+
50+
// 헤로쿠 서버 잠들기 방지
51+
cron.schedule('*/20 23,0-14 * * *', () => {
52+
http.get('http://waffle-card.herokuapp.com');
53+
console.log('wake up!', new Date());
54+
});

package-lock.json

+53-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"jsonwebtoken": "^8.5.1",
3434
"mongodb": "^4.3.1",
3535
"mongoose": "^6.2.0",
36-
"morgan": "^1.10.0"
36+
"morgan": "^1.10.0",
37+
"node-cron": "^3.0.0"
3738
}
3839
}

0 commit comments

Comments
 (0)