|
|
@@ -1,9 +1,10 @@
|
|
|
-import axios from 'axios';
|
|
|
+import axios, { AxiosError } from 'axios';
|
|
|
|
|
|
import defaults from '../../../common/defaults.module';
|
|
|
import { Logger } from '../../../common/util/logger.class';
|
|
|
|
|
|
import { Database } from './database.class';
|
|
|
+import { FCMController } from './fcm-controller.class';
|
|
|
import { Timer } from '../timer.class';
|
|
|
|
|
|
export class ServerConnector {
|
|
|
@@ -58,6 +59,19 @@ export class ServerConnector {
|
|
|
} catch (err) {
|
|
|
Logger.error('[ERROR] Server data sync failed:', err);
|
|
|
|
|
|
+ if (err instanceof AxiosError) {
|
|
|
+ if (['ECONNREFUSED', 'ECONNABORTED'].includes(err.code ?? '')) {
|
|
|
+ try {
|
|
|
+ await FCMController.instance.sendNotificationToTopic(defaults.fcmTopics.serverData, {
|
|
|
+ title: `[WARN] Server '${server.title}': daemon unreachable (${err.code})`,
|
|
|
+ body: new String(err).toString()
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ Logger.error('[ERROR] Notification failure:', err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!!trxHdl) {
|
|
|
Logger.error(`[WARN] Rolling back transaction #${trxHdl} ... `);
|
|
|
const response = await axios.delete(`http://${server.fqdn}:8890/${trxHdl}`, { responseType: 'json' });
|