From 8ea64f9de13c1a991331cc682c13704380299f9f Mon Sep 17 00:00:00 2001 From: Lucas Manchine Date: Wed, 6 Aug 2025 14:55:30 -0300 Subject: [PATCH] testing changes --- .../cluster/modify-swarm-settings.tsx | 34 +++++++++++++------ .../dokploy/drizzle/0104_free_thunderbolt.sql | 1 - apps/dokploy/drizzle/meta/_journal.json | 7 ++++ packages/server/src/db/schema/application.ts | 5 +-- packages/server/src/utils/builders/index.ts | 2 ++ packages/server/src/utils/docker/utils.ts | 2 +- 6 files changed, 36 insertions(+), 15 deletions(-) delete mode 100644 apps/dokploy/drizzle/0104_free_thunderbolt.sql diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx index a3c3179d3..289a1d15d 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx @@ -177,7 +177,7 @@ const addSwarmSettings = z.object({ modeSwarm: createStringToJSONSchema(ServiceModeSwarmSchema).nullable(), labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(), networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(), - stopGracePeriodSwarm: z.string().nullable(), + stopGracePeriodSwarm: z.bigint().nullable(), }); type AddSwarmSettings = z.infer; @@ -226,6 +226,7 @@ export const AddSwarmSettings = ({ id, type }: Props) => { modeSwarm: null, labelsSwarm: null, networkSwarm: null, + stopGracePeriodSwarm: null, }, resolver: zodResolver(addSwarmSettings), }); @@ -257,7 +258,12 @@ export const AddSwarmSettings = ({ id, type }: Props) => { networkSwarm: data.networkSwarm ? JSON.stringify(data.networkSwarm, null, 2) : null, - stopGracePeriodSwarm: data.stopGracePeriodSwarm ?? null, + stopGracePeriodSwarm: + // type === "application" && + // "stopGracePeriodSwarm" in data && + data.stopGracePeriodSwarm + ? BigInt(data.stopGracePeriodSwarm) + : null, }); } }, [form, form.reset, data]); @@ -783,12 +789,12 @@ export const AddSwarmSettings = ({ id, type }: Props) => { name="stopGracePeriodSwarm" render={({ field }) => ( - Stop Grace Period + Stop Grace Period (nanoseconds) - Check the format + Duration in nanoseconds @@ -799,11 +805,11 @@ export const AddSwarmSettings = ({ id, type }: Props) => { >
-														{`Duration string format:
-• "30s" - 30 seconds
-• "2m" - 2 minutes  
-• "1h" - 1 hour
-• "0" - no grace period`}
+														{`Enter duration in nanoseconds:
+														• 30000000000 - 30 seconds
+														• 120000000000 - 2 minutes  
+														• 3600000000000 - 1 hour
+														• 0 - no grace period`}
 													
@@ -811,10 +817,16 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
+ field.onChange( + e.target.value ? BigInt(e.target.value) : null, + ) + } />
diff --git a/apps/dokploy/drizzle/0104_free_thunderbolt.sql b/apps/dokploy/drizzle/0104_free_thunderbolt.sql
deleted file mode 100644
index e95594437..000000000
--- a/apps/dokploy/drizzle/0104_free_thunderbolt.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE "application" ADD COLUMN "stopGracePeriodSwarm" text;
\ No newline at end of file
diff --git a/apps/dokploy/drizzle/meta/_journal.json b/apps/dokploy/drizzle/meta/_journal.json
index c19599300..2575514f2 100644
--- a/apps/dokploy/drizzle/meta/_journal.json
+++ b/apps/dokploy/drizzle/meta/_journal.json
@@ -743,6 +743,13 @@
       "when": 1754259281559,
       "tag": "0105_clumsy_quicksilver",
       "breakpoints": true
+    },
+    {
+      "idx": 106,
+      "version": "7",
+      "when": 1754487585323,
+      "tag": "0106_wakeful_gressill",
+      "breakpoints": true
     }
   ]
 }
\ No newline at end of file
diff --git a/packages/server/src/db/schema/application.ts b/packages/server/src/db/schema/application.ts
index d4b039d51..e9a17e381 100644
--- a/packages/server/src/db/schema/application.ts
+++ b/packages/server/src/db/schema/application.ts
@@ -1,5 +1,6 @@
 import { relations } from "drizzle-orm";
 import {
+	bigint,
 	boolean,
 	integer,
 	json,
@@ -162,7 +163,7 @@ export const applications = pgTable("application", {
 	modeSwarm: json("modeSwarm").$type(),
 	labelsSwarm: json("labelsSwarm").$type(),
 	networkSwarm: json("networkSwarm").$type(),
-	stopGracePeriodSwarm: text("stopGracePeriodSwarm"),
+	stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }),
 	//
 	replicas: integer("replicas").default(1).notNull(),
 	applicationStatus: applicationStatus("applicationStatus")
@@ -310,7 +311,7 @@ const createSchema = createInsertSchema(applications, {
 	previewRequireCollaboratorPermissions: z.boolean().optional(),
 	watchPaths: z.array(z.string()).optional(),
 	cleanCache: z.boolean().optional(),
-	stopGracePeriodSwarm: z.string().nullable(),
+	stopGracePeriodSwarm: z.bigint().nullable(),
 });
 
 export const apiCreateApplication = createSchema.pick({
diff --git a/packages/server/src/utils/builders/index.ts b/packages/server/src/utils/builders/index.ts
index b779558ef..05275d668 100644
--- a/packages/server/src/utils/builders/index.ts
+++ b/packages/server/src/utils/builders/index.ts
@@ -142,6 +142,7 @@ export const mechanizeDockerContainer = async (
 		RollbackConfig,
 		UpdateConfig,
 		Networks,
+		StopGracePeriod,
 	} = generateConfigContainer(application);
 
 	const bindsMount = generateBindMounts(mounts);
@@ -190,6 +191,7 @@ export const mechanizeDockerContainer = async (
 			})),
 		},
 		UpdateConfig,
+		...(StopGracePeriod && { StopGracePeriod }),
 	};
 
 	try {
diff --git a/packages/server/src/utils/docker/utils.ts b/packages/server/src/utils/docker/utils.ts
index ea1766180..da908f022 100644
--- a/packages/server/src/utils/docker/utils.ts
+++ b/packages/server/src/utils/docker/utils.ts
@@ -414,7 +414,7 @@ export const generateConfigContainer = (
 					},
 				}),
 		...(stopGracePeriodSwarm && {
-			StopGracePeriod: parseInt(stopGracePeriodSwarm, 10),
+			StopGracePeriod: stopGracePeriodSwarm,
 		}),
 		...(networkSwarm
 			? {