12345678910111213141516171819202122232425262728293031 |
- const app = require('../app');
- const db = require('../model/db');
- const createFolderIsExist = require('../helpers/create-directory');
- const PORT = process.env.PORT || 3000;
- const APP_NAME = process.env.APP_NAME;
- const http = require('http');
- setInterval(() => {
- http
- .get(`http://${APP_NAME}.herokuapp.com`, function (res) {
- res.on('data', function (_chunk) {
- console.log('HEROKU RESPONSE: PINGED EVERY 25 MINUTES');
- });
- })
- .on('error', function (_err) {
- console.log('HEROKU RESPONSE: NOT PINGED');
- });
- }, 25 * 60 * 1000);
- db.then(() => {
- app.listen(PORT, async () => {
- const DIR_UPLOAD = process.env.DIR_UPLOAD;
- const DIR_STATIC = process.env.DIR_STATIC;
- await createFolderIsExist(DIR_UPLOAD);
- await createFolderIsExist(DIR_STATIC);
- console.log(`Server running. Use our API on port: ${PORT}`);
- });
- }).catch((err) => {
- console.log(`Server not running. Error message: ${err.message}`);
- process.exit(1);
- });
|