Jelajahi Sumber

address comments (#4340)

d-g-town 2 tahun lalu
induk
melakukan
452783ddbf

+ 8 - 3
dashboard/src/lib/porter-apps/services.ts

@@ -240,18 +240,23 @@ export function defaultSerialized({
     memoryThresholdPercent: 50,
     memoryThresholdPercent: 50,
   };
   };
 
 
-  const defaultHealthCheck: SerializedHealthcheck = {
+  const defaultWebHealthCheck: SerializedHealthcheck = {
     enabled: false,
     enabled: false,
     httpPath: "/healthz",
     httpPath: "/healthz",
   };
   };
 
 
+  const defaultWorkerHealthCheck: SerializedHealthcheck = {
+    enabled: false,
+    command: "./healthz.sh",
+  };
+
   return match(type)
   return match(type)
     .with("web", () => ({
     .with("web", () => ({
       ...baseService,
       ...baseService,
       config: {
       config: {
         type: "web" as const,
         type: "web" as const,
         autoscaling: defaultAutoscaling,
         autoscaling: defaultAutoscaling,
-        healthCheck: defaultHealthCheck,
+        healthCheck: defaultWebHealthCheck,
         domains: [],
         domains: [],
         private: false,
         private: false,
         ingressAnnotations: {},
         ingressAnnotations: {},
@@ -263,7 +268,7 @@ export function defaultSerialized({
       config: {
       config: {
         type: "worker" as const,
         type: "worker" as const,
         autoscaling: defaultAutoscaling,
         autoscaling: defaultAutoscaling,
-        healthCheck: defaultHealthCheck,
+        healthCheck: defaultWorkerHealthCheck,
       },
       },
     }))
     }))
     .with("job", () => ({
     .with("job", () => ({

+ 10 - 9
dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Health.tsx

@@ -10,16 +10,17 @@ import { type PorterAppFormData } from "lib/porter-apps";
 
 
 type HealthProps = {
 type HealthProps = {
   index: number;
   index: number;
-  command?: boolean;
 };
 };
 
 
-const Health: React.FC<HealthProps> = ({ index, command = false }) => {
+const Health: React.FC<HealthProps> = ({ index }) => {
   const { register, control, watch } = useFormContext<PorterAppFormData>();
   const { register, control, watch } = useFormContext<PorterAppFormData>();
 
 
   const healthCheckEnabled = watch(
   const healthCheckEnabled = watch(
     `app.services.${index}.config.healthCheck.enabled`
     `app.services.${index}.config.healthCheck.enabled`
   );
   );
 
 
+  const serviceType = watch(`app.services.${index}.config.type`);
+
   return (
   return (
     <>
     <>
       <Spacer y={1} />
       <Spacer y={1} />
@@ -60,29 +61,29 @@ const Health: React.FC<HealthProps> = ({ index, command = false }) => {
         )}
         )}
       />
       />
       {healthCheckEnabled.value &&
       {healthCheckEnabled.value &&
-        (command ? (
+        (serviceType === "web" ? (
           <>
           <>
             <Spacer y={0.5} />
             <Spacer y={0.5} />
-            <Text>Health check command</Text>
+            <Text>Health check endpoint</Text>
             <Spacer y={0.5} />
             <Spacer y={0.5} />
             <ControlledInput
             <ControlledInput
               type="text"
               type="text"
-              placeholder="ex: ./healthz.sh"
+              placeholder="ex: /healthz"
               {...register(
               {...register(
-                `app.services.${index}.config.healthCheck.command.value`
+                `app.services.${index}.config.healthCheck.httpPath.value`
               )}
               )}
             />
             />
           </>
           </>
         ) : (
         ) : (
           <>
           <>
             <Spacer y={0.5} />
             <Spacer y={0.5} />
-            <Text>Health check endpoint</Text>
+            <Text>Health check command</Text>
             <Spacer y={0.5} />
             <Spacer y={0.5} />
             <ControlledInput
             <ControlledInput
               type="text"
               type="text"
-              placeholder="ex: /healthz"
+              placeholder="ex: ./healthz.sh"
               {...register(
               {...register(
-                `app.services.${index}.config.healthCheck.httpPath.value`
+                `app.services.${index}.config.healthCheck.command.value`
               )}
               )}
             />
             />
           </>
           </>

+ 1 - 1
dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/WorkerTabs.tsx

@@ -60,7 +60,7 @@ const WorkerTabs: React.FC<Props> = ({
         ))
         ))
         .with("advanced", () => (
         .with("advanced", () => (
           <>
           <>
-            <Health index={index} command={true} />
+            <Health index={index} />
             <Spacer y={1} />
             <Spacer y={1} />
             <Advanced index={index} />
             <Advanced index={index} />
           </>
           </>

+ 1 - 1
internal/porter_app/v2/yaml.go

@@ -211,7 +211,7 @@ type Domains struct {
 	Name string `yaml:"name"`
 	Name string `yaml:"name"`
 }
 }
 
 
-// HealthCheck is the health check settings for a web service
+// HealthCheck contains the health check settings
 type HealthCheck struct {
 type HealthCheck struct {
 	Enabled  bool   `yaml:"enabled"`
 	Enabled  bool   `yaml:"enabled"`
 	HttpPath string `yaml:"httpPath"`
 	HttpPath string `yaml:"httpPath"`