mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-18 18:05:18 +00:00
feat(server): add monitoring configuration for cloud setup
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { paths } from "@dokploy/server/constants";
|
import { IS_CLOUD, paths } from "@dokploy/server/constants";
|
||||||
|
import { getDokployUrl } from "@dokploy/server/services/admin";
|
||||||
import {
|
import {
|
||||||
createServerDeployment,
|
createServerDeployment,
|
||||||
updateDeploymentStatus,
|
updateDeploymentStatus,
|
||||||
} from "@dokploy/server/services/deployment";
|
} from "@dokploy/server/services/deployment";
|
||||||
import { findServerById } from "@dokploy/server/services/server";
|
import {
|
||||||
|
findServerById,
|
||||||
|
updateServerById,
|
||||||
|
} from "@dokploy/server/services/server";
|
||||||
import {
|
import {
|
||||||
getDefaultMiddlewares,
|
getDefaultMiddlewares,
|
||||||
getDefaultServerTraefikConfig,
|
getDefaultServerTraefikConfig,
|
||||||
@@ -16,6 +20,7 @@ import {
|
|||||||
import slug from "slugify";
|
import slug from "slugify";
|
||||||
import { Client } from "ssh2";
|
import { Client } from "ssh2";
|
||||||
import { recreateDirectory } from "../utils/filesystem/directory";
|
import { recreateDirectory } from "../utils/filesystem/directory";
|
||||||
|
import { setupMonitoring } from "./monitoring-setup";
|
||||||
|
|
||||||
export const slugify = (text: string | undefined) => {
|
export const slugify = (text: string | undefined) => {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
@@ -59,6 +64,38 @@ export const serverSetup = async (
|
|||||||
);
|
);
|
||||||
await installRequirements(serverId, onData);
|
await installRequirements(serverId, onData);
|
||||||
|
|
||||||
|
if (IS_CLOUD) {
|
||||||
|
onData?.("\nConfiguring Monitoring: 🔄\n");
|
||||||
|
|
||||||
|
// Generate token and configure monitoring
|
||||||
|
const generateToken = () => {
|
||||||
|
const array = new Uint8Array(64);
|
||||||
|
crypto.getRandomValues(array);
|
||||||
|
return Array.from(array, (byte) =>
|
||||||
|
byte.toString(16).padStart(2, "0"),
|
||||||
|
).join("");
|
||||||
|
};
|
||||||
|
|
||||||
|
const baseUrl = await getDokployUrl();
|
||||||
|
const token = generateToken();
|
||||||
|
const urlCallback = `${baseUrl}/api/trpc/notification.receiveNotification`;
|
||||||
|
|
||||||
|
// Update server with monitoring configuration
|
||||||
|
await updateServerById(serverId, {
|
||||||
|
metricsConfig: {
|
||||||
|
server: {
|
||||||
|
...server.metricsConfig.server,
|
||||||
|
token: token,
|
||||||
|
urlCallback: urlCallback,
|
||||||
|
},
|
||||||
|
containers: server.metricsConfig.containers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await setupMonitoring(serverId);
|
||||||
|
onData?.("\nMonitoring Configured: ✅\n");
|
||||||
|
}
|
||||||
|
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "done");
|
await updateDeploymentStatus(deployment.deploymentId, "done");
|
||||||
|
|
||||||
onData?.("\nSetup Server: ✅\n");
|
onData?.("\nSetup Server: ✅\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user