Skip to content

Commit

Permalink
refactor: update path
Browse files Browse the repository at this point in the history
  • Loading branch information
Siumauricio committed Jan 1, 2025
1 parent 9dc10fa commit 7fd6436
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ export const SetupMonitoring = ({ serverId }: Props) => {
onValueChange={setSearch}
/>
<CommandEmpty>No service found.</CommandEmpty>
<CommandGroup>
<ScrollArea className="h-[200px]">
<CommandGroup className="max-h-[200px] overflow-hidden">
<ScrollArea className="h-[200px]" onWheel={(e) => e.stopPropagation()}>
{availableServices?.map((service) => (
<CommandItem
key={service}
Expand Down Expand Up @@ -332,8 +332,8 @@ export const SetupMonitoring = ({ serverId }: Props) => {
onValueChange={setSearchExclude}
/>
<CommandEmpty>No service found.</CommandEmpty>
<CommandGroup>
<ScrollArea className="h-[200px]">
<CommandGroup className="max-h-[200px] overflow-hidden">
<ScrollArea className="h-[200px]" onWheel={(e) => e.stopPropagation()}>
{availableServicesToExclude.map((service) => (
<CommandItem
key={service}
Expand Down
10 changes: 5 additions & 5 deletions apps/dokploy/server/api/routers/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ export const serverRouter = createTRPCRouter({
containerRefreshRateMetrics: input.containerRefreshRateMetrics,
serverRefreshRateMetrics: input.serverRefreshRateMetrics,
containersMetricsDefinition: {
includeServices: input.containersMetricsDefinition.includeServices,
includeServices:
input?.containersMetricsDefinition?.includeServices ?? [],
excludedServices:
input.containersMetricsDefinition.excludedServices,
input?.containersMetricsDefinition?.excludedServices ?? [],
},
});
// const currentServer = await setupMonitoring(input.serverId);
// return currentServer;
return true;
const currentServer = await setupMonitoring(input.serverId);
return currentServer;
} catch (error) {
throw error;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/monitoring/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import path from "node:path";

export const serverLogFile = path.join(
process.env.NODE_ENV === "production"
? "/etc"
? "/etc/dokploy/monitoring"
: "/Users/mauricio/Documents/Github/Personal/dokploy/apps/dokploy/.docker",
"server_metrics.log",
);
export const containerLogFile = path.join(
process.env.NODE_ENV === "production"
? "/etc"
? "/etc/dokploy/monitoring"
: "/Users/mauricio/Documents/Github/Personal/dokploy/apps/dokploy/.docker/monitoring",
);
6 changes: 3 additions & 3 deletions apps/monitoring/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ app.use(
}),
);

logServerMetrics();
logContainerMetrics();

app.use("/*", cors());
// app.use(
// "/*",
Expand Down Expand Up @@ -100,6 +103,3 @@ serve({
fetch: app.fetch,
port,
});

logServerMetrics();
logContainerMetrics();
4 changes: 2 additions & 2 deletions apps/monitoring/src/monitoring/containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const DEFAULT_CONFIG: MonitoringConfig = {
// Cargar la configuración desde la variable de entorno
const loadConfig = (): MonitoringConfig => {
try {
const configJson = process.env.MONITORING_CONFIG;
const configJson = process.env.CONTAINER_MONITORING_CONFIG;

if (!configJson) {
return DEFAULT_CONFIG;
Expand All @@ -50,7 +50,7 @@ const loadConfig = (): MonitoringConfig => {

const config = loadConfig();
const REFRESH_RATE_CONTAINER = Number(
process.env.CONTAINER_REFRESH_RATE || 8000,
process.env.CONTAINER_REFRESH_RATE || 10000,
);

interface Container {
Expand Down
2 changes: 1 addition & 1 deletion apps/monitoring/src/monitoring/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const getServerMetrics = async () => {
};
};

const REFRESH_RATE_SERVER = Number(process.env.REFRESH_RATE_SERVER || 5000);
const REFRESH_RATE_SERVER = Number(process.env.REFRESH_RATE_SERVER || 10000);
const MAX_FILE_SIZE_MB = Number(process.env.MAX_FILE_SIZE_MB || 10); // 10 MB por defecto

export const logServerMetrics = () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/server/src/setup/monitoring-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export const setupMonitoring = async (serverId: string) => {
const settings: ContainerCreateOptions = {
name: containerName,
Env: [
`REFRESH_RATE_SERVER=${server.refreshRateMetrics * 1000}`,
`REFRESH_RATE_SERVER=${server.serverRefreshRateMetrics * 1000}`,
`CONTAINER_REFRESH_RATE=${server.containerRefreshRateMetrics * 1000}`,
`CONTAINER_MONITORING_CONFIG=${JSON.stringify(
server?.containersMetricsDefinition,
)}`,
`PORT=${server.defaultPortMetrics}`,
],
Image: imageName,
Expand All @@ -31,6 +35,7 @@ export const setupMonitoring = async (serverId: string) => {
"/var/run/docker.sock:/var/run/docker.sock:ro",
"/sys:/host/sys:ro",
"/etc/os-release:/etc/os-release:ro",
"/etc/dokploy/monitoring:/etc/dokploy/monitoring",
// "/proc/cpuinfo:/proc/cpuinfo:ro",
// "/proc/cpuinfo:/host/proc/cpuinfo:ro",
],
Expand Down

0 comments on commit 7fd6436

Please sign in to comment.