mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor main files
This commit is contained in:
@@ -1,21 +1,5 @@
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unhandled rejection in process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
@@ -25,7 +9,7 @@ import compression from 'compression';
|
||||
|
||||
app.use(compression());
|
||||
|
||||
app.get(['/env.js', '/accounts/env.js'], function(
|
||||
app.get(['/env.js', '/accounts/env.js'], function (
|
||||
req: $TSFixMe,
|
||||
res: $TSFixMe
|
||||
) {
|
||||
@@ -85,7 +69,7 @@ app.use(
|
||||
|
||||
app.use('/accounts', express.static(path.join(__dirname, 'build')));
|
||||
|
||||
app.get('/*', function(req: Request, res: Response) {
|
||||
app.get('/*', function (req: Request, res: Response) {
|
||||
res.sendFile(path.join(__dirname, 'build', 'index.html'));
|
||||
});
|
||||
|
||||
|
||||
@@ -1,31 +1,5 @@
|
||||
const { NODE_ENV } = process.env;
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /backend/.env
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Application Scanner Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(
|
||||
'Unhandled rejection in application scanner process occurred'
|
||||
);
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in application scanner process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
@@ -44,7 +18,7 @@ const cronApplicationSecurityStartTime = Math.floor(Math.random() * 50);
|
||||
app.use(cors());
|
||||
app.set('port', process.env.PORT || 3005);
|
||||
|
||||
app.get(['/application/status', '/status'], function(
|
||||
app.get(['/application/status', '/status'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -60,7 +34,7 @@ app.get(['/application/status', '/status'], function(
|
||||
|
||||
//App Version
|
||||
|
||||
app.get(['/application/version', '/version'], function(
|
||||
app.get(['/application/version', '/version'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -75,7 +49,7 @@ cron.schedule('*/5 * * * *', () => {
|
||||
}, cronApplicationSecurityStartTime * 1000);
|
||||
});
|
||||
|
||||
http.listen(app.get('port'), function() {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log(
|
||||
`Application Scanner Started on port ${app.get(
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
const { NODE_ENV } = process.env;
|
||||
import dotenv from 'dotenv';
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
dotenv.config();
|
||||
}
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import express from 'express';
|
||||
import logger from 'common-server/utils/logger';
|
||||
@@ -13,20 +10,6 @@ const app = express();
|
||||
|
||||
app.use(expressRequestId);
|
||||
|
||||
process.on('exit', () => {
|
||||
logger.info('Server Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
logger.error('Unhandled rejection in server process occurred');
|
||||
logger.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
logger.error('Uncaught exception in server process occurred');
|
||||
logger.error(err);
|
||||
});
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import http from 'http';
|
||||
@@ -80,7 +63,7 @@ global.io = io;
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.use(async function(req: Request, res: Response, next: Function) {
|
||||
app.use(async function (req: Request, res: Response, next: Function) {
|
||||
const method = req.method;
|
||||
const url = req.url;
|
||||
const requestStartedAt = Date.now();
|
||||
@@ -102,20 +85,18 @@ app.use(async function(req: Request, res: Response, next: Function) {
|
||||
req.logdata = logdata;
|
||||
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${
|
||||
process.env.POD_NAME
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${process.env.POD_NAME
|
||||
} -- RECEIVED AT: ${new Date()} -- METHOD: ${method} -- URL: ${url}`
|
||||
);
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- REQUEST BODY: ${
|
||||
req.body ? JSON.stringify(req.body, null, 2) : 'EMPTY'
|
||||
`INCOMING REQUEST ID: ${req.id} -- REQUEST BODY: ${req.body ? JSON.stringify(req.body, null, 2) : 'EMPTY'
|
||||
}`
|
||||
);
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(function (req: Request, res: Response, next: Function) {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
}
|
||||
@@ -482,7 +463,7 @@ app.use(
|
||||
|
||||
app.use(['/api'], require('./backend/api/apiStatus'));
|
||||
|
||||
app.use('/*', function(req: Request, res: Response) {
|
||||
app.use('/*', function (req: Request, res: Response) {
|
||||
res.status(404).send('Endpoint not found.');
|
||||
});
|
||||
|
||||
@@ -491,7 +472,7 @@ require('./backend/workers/main');
|
||||
|
||||
app.set('port', process.env.PORT || 3002);
|
||||
|
||||
const server = http.listen(app.get('port'), function() {
|
||||
const server = http.listen(app.get('port'), function () {
|
||||
logger.info('Server Started on port ' + app.get('port'));
|
||||
});
|
||||
|
||||
@@ -504,7 +485,7 @@ mongoose.connection.on('connected', async () => {
|
||||
maintainerEmail: 'certs@oneuptime.com',
|
||||
staging: false,
|
||||
|
||||
notify: function(event, details) {
|
||||
notify: function (event, details) {
|
||||
if ('error' === event) {
|
||||
// `details` is an error object in this case
|
||||
// eslint-disable-next-line no-console
|
||||
@@ -534,6 +515,6 @@ mongoose.connection.on('connected', async () => {
|
||||
});
|
||||
|
||||
export default app;
|
||||
module.exports.close = function() {
|
||||
module.exports.close = function () {
|
||||
server.close();
|
||||
};
|
||||
|
||||
@@ -1,29 +1,5 @@
|
||||
const { NODE_ENV } = process.env;
|
||||
import dotenv from 'dotenv';
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /backend/.env
|
||||
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Container Scanner Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unhandled rejection in container scanner process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in container scanner process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
@@ -42,7 +18,7 @@ const cronContainerSecurityStartTime = Math.floor(Math.random() * 50);
|
||||
app.use(cors());
|
||||
app.set('port', process.env.PORT || 3055);
|
||||
|
||||
app.get(['/container/status', '/status'], function(
|
||||
app.get(['/container/status', '/status'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -58,7 +34,7 @@ app.get(['/container/status', '/status'], function(
|
||||
|
||||
//App Version
|
||||
|
||||
app.get(['/container/version', '/version'], function(
|
||||
app.get(['/container/version', '/version'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -73,7 +49,7 @@ cron.schedule('*/5 * * * *', () => {
|
||||
}, cronContainerSecurityStartTime * 1000);
|
||||
});
|
||||
|
||||
http.listen(app.get('port'), function() {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log(
|
||||
`Container Scanner Started on port ${app.get(
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
const { NODE_ENV } = process.env;
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /data-ingestor/.env
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
|
||||
@@ -17,19 +12,6 @@ import cors from 'cors';
|
||||
import { mongoUrl, databaseName } from './utils/config';
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
|
||||
process.on('exit', () => {
|
||||
console.log('Server Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
console.error('Unhandled rejection in server process occurred');
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
console.error('Uncaught exception in server process occurred');
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
// mongodb
|
||||
function getMongoClient() {
|
||||
@@ -40,7 +22,7 @@ function getMongoClient() {
|
||||
}
|
||||
// setup mongodb connection
|
||||
const client = getMongoClient();
|
||||
(async function() {
|
||||
(async function () {
|
||||
try {
|
||||
console.log('connecting to db');
|
||||
await client.connect();
|
||||
@@ -56,7 +38,7 @@ global.db = client.db(databaseName);
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(function (req: Request, res: Response, next: Function) {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
}
|
||||
@@ -85,7 +67,7 @@ const getActualRequestDurationInMilliseconds = start => {
|
||||
return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS;
|
||||
};
|
||||
|
||||
app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(function (req: Request, res: Response, next: Function) {
|
||||
const current_datetime = new Date();
|
||||
const formatted_date =
|
||||
current_datetime.getFullYear() +
|
||||
@@ -111,7 +93,7 @@ app.use(function(req: Request, res: Response, next: Function) {
|
||||
return next();
|
||||
});
|
||||
|
||||
app.get(['/data-ingestor/status', '/status'], function(
|
||||
app.get(['/data-ingestor/status', '/status'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -129,7 +111,7 @@ app.use(['/probe', '/api/probe'], require('./api/probe'));
|
||||
|
||||
app.set('port', process.env.PORT || 3200);
|
||||
|
||||
http.listen(app.get('port'), function() {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log('data-ingestor server started on port ' + app.get('port'));
|
||||
});
|
||||
|
||||
@@ -1,29 +1,5 @@
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unhandled rejection in process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
const { NODE_ENV } = process.env;
|
||||
import dotenv from 'dotenv';
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /backend/.env
|
||||
|
||||
dotenv.config();
|
||||
}
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import fs from 'fs';
|
||||
import util from './util/db';
|
||||
@@ -62,16 +38,16 @@ if (process.env['NODE_ENV'] === 'development') {
|
||||
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }));
|
||||
app.use(bodyParser.json({ limit: '10mb' }));
|
||||
|
||||
app.listen(1447, function() {
|
||||
app.listen(1447, function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Server running on: 1447');
|
||||
});
|
||||
|
||||
app.get('/:dbFunction', async function(req: Request, res: Response) {
|
||||
app.get('/:dbFunction', async function (req: Request, res: Response) {
|
||||
return await interactWithDB(req, res);
|
||||
});
|
||||
|
||||
app.post('/:dbFunction', async function(req: Request, res: Response) {
|
||||
app.post('/:dbFunction', async function (req: Request, res: Response) {
|
||||
return await interactWithDB(req, res);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
* @see module:logger
|
||||
*/
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
import Promise from 'promise';
|
||||
|
||||
@@ -111,9 +109,9 @@ const ping = (
|
||||
const storage =
|
||||
data[2] && data[2].length > 0
|
||||
? data[2].filter(
|
||||
partition =>
|
||||
partition.size === data[2][0].size
|
||||
)
|
||||
partition =>
|
||||
partition.size === data[2][0].size
|
||||
)
|
||||
: data[2];
|
||||
return {
|
||||
cpuLoad: data[0].currentLoad,
|
||||
@@ -125,11 +123,11 @@ const ping = (
|
||||
storageUsed:
|
||||
storage && storage.length > 0
|
||||
? storage
|
||||
.map(partition => partition.used)
|
||||
.reduce(
|
||||
(used, partitionUsed) =>
|
||||
used + partitionUsed
|
||||
)
|
||||
.map(partition => partition.used)
|
||||
.reduce(
|
||||
(used, partitionUsed) =>
|
||||
used + partitionUsed
|
||||
)
|
||||
: storage.used,
|
||||
totalStorage:
|
||||
storage && storage.length > 0
|
||||
@@ -138,11 +136,11 @@ const ping = (
|
||||
storageUsage:
|
||||
storage && storage.length > 0
|
||||
? storage
|
||||
.map(partition => partition.use)
|
||||
.reduce(
|
||||
(use, partitionUse) =>
|
||||
use + partitionUse
|
||||
)
|
||||
.map(partition => partition.use)
|
||||
.reduce(
|
||||
(use, partitionUse) =>
|
||||
use + partitionUse
|
||||
)
|
||||
: storage.use,
|
||||
mainTemp: data[3].main,
|
||||
maxTemp: data[3].max,
|
||||
@@ -182,7 +180,7 @@ const ping = (
|
||||
* @return {Object} The server monitor handlers.
|
||||
*/
|
||||
|
||||
export default function(
|
||||
export default function (
|
||||
config: $TSFixMe,
|
||||
apiUrl: $TSFixMe,
|
||||
apiKey: $TSFixMe,
|
||||
@@ -213,9 +211,8 @@ export default function(
|
||||
* @return {(Object | number)} The ping server cron job or the error code.
|
||||
*/
|
||||
start: (id = monitorId) => {
|
||||
const url = `monitor/${projectId}/monitor/${
|
||||
id && typeof id === 'string' ? `${id}/` : ''
|
||||
}?type=server-monitor`;
|
||||
const url = `monitor/${projectId}/monitor/${id && typeof id === 'string' ? `${id}/` : ''
|
||||
}?type=server-monitor`;
|
||||
|
||||
return get(apiUrl, url, apiKey, (response: $TSFixMe) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
|
||||
const { NODE_ENV } = process.env;
|
||||
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /licensing/.env
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Server Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in server process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import path from 'path';
|
||||
|
||||
@@ -33,7 +16,7 @@ import cors from 'cors';
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(function (req: Request, res: Response, next: Function) {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
}
|
||||
@@ -63,12 +46,12 @@ app.use('/', express.static(path.join(__dirname, 'views', 'img')));
|
||||
app.use('/license/validate', require('./src/api/license'));
|
||||
app.set('port', process.env.PORT || 3004);
|
||||
|
||||
const server = http.listen(app.get('port'), function() {
|
||||
const server = http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log('Server Started on port ' + app.get('port'));
|
||||
});
|
||||
|
||||
app.get(['/', '/license'], function(req: Request, res: Response) {
|
||||
app.get(['/', '/license'], function (req: Request, res: Response) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -79,11 +62,11 @@ app.get(['/', '/license'], function(req: Request, res: Response) {
|
||||
);
|
||||
});
|
||||
|
||||
app.use('/*', function(req: Request, res: Response) {
|
||||
app.use('/*', function (req: Request, res: Response) {
|
||||
res.status(404).render('notFound.ejs', {});
|
||||
});
|
||||
|
||||
export default app;
|
||||
module.exports.close = function() {
|
||||
module.exports.close = function () {
|
||||
server.close();
|
||||
};
|
||||
|
||||
@@ -1,30 +1,6 @@
|
||||
const { NODE_ENV } = process.env;
|
||||
import dotenv from 'dotenv';
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /backend/.env
|
||||
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Lighthouse Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unhandled rejection in Lighthouse process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in Lighthouse process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
|
||||
@@ -42,7 +18,7 @@ const cronMinuteStartTime = Math.floor(Math.random() * 50);
|
||||
app.use(cors());
|
||||
app.set('port', process.env.PORT || 3015);
|
||||
|
||||
app.get(['/lighthouse/status', '/status'], function(
|
||||
app.get(['/lighthouse/status', '/status'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -58,7 +34,7 @@ app.get(['/lighthouse/status', '/status'], function(
|
||||
|
||||
//App Version
|
||||
|
||||
app.get(['/lighthouse/version', '/version'], function(
|
||||
app.get(['/lighthouse/version', '/version'], function (
|
||||
req: Request,
|
||||
res: Response
|
||||
) {
|
||||
@@ -73,11 +49,10 @@ cron.schedule('*/30 * * * *', () => {
|
||||
}, cronMinuteStartTime * 1000);
|
||||
});
|
||||
|
||||
http.listen(app.get('port'), function() {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log(
|
||||
`Lighthouse Started on port ${app.get('port')}. OneUptime API URL: ${
|
||||
config.serverUrl
|
||||
`Lighthouse Started on port ${app.get('port')}. OneUptime API URL: ${config.serverUrl
|
||||
}`
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,29 +2,8 @@ const { NODE_ENV } = process.env;
|
||||
|
||||
import asyncSleep from 'await-sleep';
|
||||
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Probe Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unhandled rejection in probe process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in probe process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import Main from './workers/main';
|
||||
import config from './utils/config';
|
||||
|
||||
@@ -1,25 +1,5 @@
|
||||
/* eslint-disable no-console */
|
||||
const { NODE_ENV } = process.env;
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /data-ingestor/.env
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
console.log('Server Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
console.error('Unhandled rejection in server process occurred');
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
console.error('Uncaught exception in server process occurred');
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
|
||||
@@ -90,7 +70,7 @@ io.sockets.on('connection', socket => {
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(function (req: Request, res: Response, next: Function) {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
}
|
||||
@@ -110,7 +90,7 @@ app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(express.urlencoded({ limit: '50mb', extended: true }));
|
||||
app.use(express.json({ limit: '50mb' }));
|
||||
|
||||
app.get(['/realtime/status', '/status'], function(req: Request, res: Response) {
|
||||
app.get(['/realtime/status', '/status'], function (req: Request, res: Response) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -125,7 +105,7 @@ app.use('/realtime', require('./api/realtime'));
|
||||
|
||||
app.set('port', process.env.PORT || 3300);
|
||||
|
||||
http.listen(app.get('port'), function() {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log('realtime server started on port ' + app.get('port'));
|
||||
});
|
||||
|
||||
@@ -1,28 +1,6 @@
|
||||
const { NODE_ENV } = process.env;
|
||||
import dotenv from 'dotenv';
|
||||
if (!NODE_ENV || NODE_ENV === 'development') {
|
||||
// Load env vars from /backend/.env
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Script runner Shutting Shutdown');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unhandled rejection in Script runner process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Uncaught exception in Script runner process occurred');
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
});
|
||||
import 'common-server/utils/env';
|
||||
import 'common-server/utils/process';
|
||||
|
||||
import express from 'express';
|
||||
const app = express();
|
||||
@@ -39,7 +17,7 @@ import main from './workers/main';
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.use(function(req: Request, res: Response, next: Function) {
|
||||
app.use(function (req: Request, res: Response, next: Function) {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
}
|
||||
@@ -59,7 +37,7 @@ app.set('port', process.env.PORT || 3009);
|
||||
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }));
|
||||
app.use(bodyParser.json({ limit: '10mb' }));
|
||||
|
||||
app.get(['/script/status', '/status'], function(req: Request, res: Response) {
|
||||
app.get(['/script/status', '/status'], function (req: Request, res: Response) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
@@ -72,7 +50,7 @@ app.get(['/script/status', '/status'], function(req: Request, res: Response) {
|
||||
|
||||
app.use('/script', require('./api/script'));
|
||||
|
||||
http.listen(app.get('port'), function() {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
console.log('Script runner started on port ' + app.get('port'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user