Skip to content

Commit

Permalink
Strict string launch arg value
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Nov 24, 2024
1 parent 6aaa687 commit f3c8299
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/config/comfySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const DEFAULT_SETTINGS: ComfySettingsData = {
export interface ComfySettingsData {
'Comfy-Desktop.AutoUpdate': boolean;
'Comfy-Desktop.SendStatistics': boolean;
'Comfy.Server.LaunchArgs': Record<string, string | boolean>;
'Comfy.Server.LaunchArgs': Record<string, string>;
[key: string]: unknown;
}

Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const DEFAULT_SERVER_ARGS = {
/** The port to use for the ComfyUI server. */
port: 8000,
// Extra arguments to pass to the ComfyUI server.
extraServerArgs: {} as Record<string, string | boolean>,
extraServerArgs: {} as Record<string, string>,
};

export type ServerArgs = typeof DEFAULT_SERVER_ARGS;
Expand Down
4 changes: 2 additions & 2 deletions src/main-process/comfyServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class ComfyServer {
})
.map(([key, value]) => [`--${key}`, value])
.flat()
// Boolean true values are ignored. e.g. { '--cpu': true } => '--cpu'
.filter((value: string | boolean) => typeof value === 'string' && value !== '')
// Empty string values are ignored. e.g. { '--cpu': '' } => '--cpu'
.filter((value: string) => value !== '')
);
}

Expand Down
5 changes: 2 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ if (!gotTheLock) {
const host = process.env.COMFY_HOST || DEFAULT_SERVER_ARGS.host;
const targetPort = process.env.COMFY_PORT ? parseInt(process.env.COMFY_PORT) : DEFAULT_SERVER_ARGS.port;
const port = useExternalServer ? targetPort : await findAvailablePort(host, targetPort, targetPort + 1000);
const cpuOnly: Record<string, string | boolean> =
process.env.COMFYUI_CPU_ONLY === 'true' ? { '--cpu': true } : {};
const extraServerArgs: Record<string, string | boolean> = {
const cpuOnly: Record<string, string> = process.env.COMFYUI_CPU_ONLY === 'true' ? { '--cpu': '' } : {};
const extraServerArgs: Record<string, string> = {
...comfyDesktopApp.comfySettings.get('Comfy.Server.LaunchArgs'),
...cpuOnly,
};
Expand Down

0 comments on commit f3c8299

Please sign in to comment.