Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/be/docker monitors, references #1139 #1150

Merged
merged 15 commits into from
Nov 14, 2024
Merged
2 changes: 1 addition & 1 deletion Server/db/models/Monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const MonitorSchema = mongoose.Schema(
type: {
type: String,
required: true,
enum: ["http", "ping", "pagespeed", "hardware"],
enum: ["http", "ping", "pagespeed", "hardware", "docker"],
},
url: {
type: String,
Expand Down
5 changes: 3 additions & 2 deletions Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import NetworkService from "./service/networkService.js";
import axios from "axios";
import ping from "ping";
import http from "http";
import Docker from "dockerode";

// Email service and dependencies
import EmailService from "./service/emailService.js";
Expand All @@ -45,7 +46,7 @@ import NotificationService from "./service/notificationService.js";

import db from "./db/mongo/MongoDB.js";
const SERVICE_NAME = "Server";
const SHUTDOWN_TIMEOUT = 0;
const SHUTDOWN_TIMEOUT = 1000;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Timeout's looking kinda slim, chief! 🍝

While changing from 0 to 1000ms is an improvement, Docker operations might need more time to clean up gracefully. Consider increasing this value further.

-const SHUTDOWN_TIMEOUT = 1000;
+const SHUTDOWN_TIMEOUT = 5000; // 5 seconds to allow Docker containers to cleanup
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const SHUTDOWN_TIMEOUT = 1000;
const SHUTDOWN_TIMEOUT = 5000; // 5 seconds to allow Docker containers to cleanup


let isShuttingDown = false;
const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -130,7 +131,7 @@ const startApp = async () => {
nodemailer,
logger
);
const networkService = new NetworkService(axios, ping, logger, http);
const networkService = new NetworkService(axios, ping, logger, http, Docker);
const statusService = new StatusService(db, logger);
const notificationService = new NotificationService(emailService, db, logger);
const jobQueue = await JobQueue.createJobQueue(
Expand Down
Loading