fixed unwanted closing connections

This commit is contained in:
Jan Prochazka
2021-01-23 08:44:41 +01:00
parent fa29bc65dc
commit 19a39d4a83
3 changed files with 16 additions and 11 deletions

View File

@@ -120,7 +120,7 @@ function start() {
setInterval(() => {
const time = new Date().getTime();
if (time - lastPing > 60 * 1000) {
if (time - lastPing > 120 * 1000) {
console.log('Database connection not alive, exiting');
process.exit(0);
}

View File

@@ -89,7 +89,8 @@ function start() {
setInterval(() => {
const time = new Date().getTime();
if (time - lastPing > 60 * 1000) {
if (time - lastPing > 120 * 1000) {
console.log('Server connection not alive, exiting');
process.exit(0);
}
}, 60 * 1000);

View File

@@ -6,16 +6,20 @@ import axios from './axios';
export default function ConnectionsPinger({ children }) {
const openedConnections = useOpenedConnections();
const currentDatabase = useCurrentDatabase();
React.useEffect(() => {
const handle = window.setInterval(() => {
axios.post('server-connections/ping', { connections: openedConnections });
const database = _.get(currentDatabase, 'name');
const conid = _.get(currentDatabase, 'connection._id');
if (conid && database) {
axios.post('database-connections/ping', { conid, database });
}
}, 30 * 1000);
const doPing = () => {
axios.post('server-connections/ping', { connections: openedConnections });
const database = _.get(currentDatabase, 'name');
const conid = _.get(currentDatabase, 'connection._id');
if (conid && database) {
axios.post('database-connections/ping', { conid, database });
}
};
React.useEffect(() => {
doPing();
const handle = window.setInterval(doPing, 30 * 1000);
return () => window.clearInterval(handle);
}, [openedConnections, currentDatabase]);
return children;