diff --git a/apps/backend/utils/processInfo.ts b/apps/backend/utils/processInfo.ts index 6930adc..911b8d4 100644 --- a/apps/backend/utils/processInfo.ts +++ b/apps/backend/utils/processInfo.ts @@ -1,3 +1,4 @@ +import { IProcessType, PROCESS_TYPES } from "@pm2.web/typings"; import bytes from "bytes-iec"; import pm2 from "pm2"; @@ -26,6 +27,8 @@ const getProcessInfo = async (): Promise => { unit: "", }; + const interpreter = item?.pm2_env?.exec_interpreter; + return { name: item.name || item.pm_id, pm_id: item.pm_id, @@ -44,7 +47,9 @@ const getProcessInfo = async (): Promise => { unstaged: item.pm2_env?.versioning?.unstaged ?? true, }, status: item?.pm2_env?.status || "offline", - type: item?.pm2_env?.exec_interpreter || "", + type: PROCESS_TYPES.includes(interpreter as IProcessType) + ? interpreter + : "other", }; }) .filter((item) => !!item) as IProcessInfo[]; diff --git a/packages/typings/src/process.ts b/packages/typings/src/process.ts index bf11d39..6518b00 100644 --- a/packages/typings/src/process.ts +++ b/packages/typings/src/process.ts @@ -7,17 +7,20 @@ interface ILog { _id: string; } -type IProcessType = - | "node" - | "python" - | "ruby" - | "php" - | "bash" - | "go" - | "dotnet" - | "shell" - | "java" - | "other"; +const PROCESS_TYPES = [ + "node", + "python", + "ruby", + "php", + "bash", + "go", + "dotnet", + "shell", + "java", + "other", +] + +type IProcessType = typeof PROCESS_TYPES[number]; type IProcessStatus = | "online" @@ -58,5 +61,9 @@ export type { IProcessType, IProcessStatus, IProcess, - IProcessModel, + IProcessModel }; + +export { + PROCESS_TYPES +}