The project is working normally. But sometimes I try to enter the site after 1 week and the site cannot be reached. I provide control on the Linux side, the client and server side are working, but it says the site cannot be reached. I run the commands below, I stand up again, it gets better, and it happens again after 1 week. I put a logger for the server side, it doesn't get any errors. What could be the problem?
When I write these codes, I restart the system and start it again, and it works, then breaks down again after 1 week. 1.sudo service ssh restart 2.sudo systemctl restart nginx 3.pm2kill 4.pm2 start server.js 5.pm2 start npm -- start
BackEnd : NodeJs,Express,Mongo FrontEnd : React
This is my backend server.js
const express = require('express');
const mongoose = require('mongoose');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const cors = require('cors');
const { readdirSync } = require('fs');
const logger = require('./logger');
require('dotenv').config();
// app
const app = express();
// db
mongoose
.connect(process.env.DATABASE, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
})
.then(() => console.log('DB CONNECTED'))
.catch((err) => console.log('DB CONNECTION ERR', err));
// middlewares
app.use(morgan('dev'));
app.use(bodyParser.json({ limit: '2mb' }));
app.use(cors());
// routes middleware
readdirSync('./routes').map((r) => app.use('/api', require('./routes/' + r)));
// port
const port = process.env.PORT || 8000;
logger.error('error');
logger.warn('warn');
logger.info('info');
logger.verbose('verbose');
logger.debug('debug');
logger.silly('silly');
app.listen(port, () => {
logger.info('app is running');
});
[1]: https://i.stack.imgur.com/XYbdk.png
[2]: https://i.stack.imgur.com/vKs33.png