Skip to content

Commit

Permalink
Merge pull request #41 from oxdev03/change-fix-process-type
Browse files Browse the repository at this point in the history
fix: invalid process type, fixes #40
  • Loading branch information
oxdev03 committed Sep 7, 2024
2 parents ebab35d + d509ffc commit 5faa546
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
7 changes: 6 additions & 1 deletion apps/backend/utils/processInfo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IProcessType, PROCESS_TYPES } from "@pm2.web/typings";
import bytes from "bytes-iec";
import pm2 from "pm2";

Expand Down Expand Up @@ -26,6 +27,8 @@ const getProcessInfo = async (): Promise<IProcessInfo[]> => {
unit: "",
};

const interpreter = item?.pm2_env?.exec_interpreter;

return {
name: item.name || item.pm_id,
pm_id: item.pm_id,
Expand All @@ -44,7 +47,9 @@ const getProcessInfo = async (): Promise<IProcessInfo[]> => {
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[];
Expand Down
31 changes: 19 additions & 12 deletions packages/typings/src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ interface ILog {
_id: string;
}

type IProcessType =
| "node"
| "python"
| "ruby"
| "php"
| "bash"
| "go"
| "dotnet"
| "shell"
| "java"
| "other";
const PROCESS_TYPES = <const> [
"node",
"python",
"ruby",
"php",
"bash",
"go",
"dotnet",
"shell",
"java",
"other",
]

type IProcessType = typeof PROCESS_TYPES[number];

type IProcessStatus =
| "online"
Expand Down Expand Up @@ -58,5 +61,9 @@ export type {
IProcessType,
IProcessStatus,
IProcess,
IProcessModel,
IProcessModel
};

export {
PROCESS_TYPES
}

0 comments on commit 5faa546

Please sign in to comment.