From f00b2497086232d409c63a3c0fe8706458314b66 Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 5 Dec 2025 18:11:27 +0100 Subject: [PATCH] Documentation for socket activation Also: move github actions out of the way to prevent involuntary execution. --- .../api-node-template.yml | 0 .../check-line-endings.yml | 0 .../pullrequest-ci-run.yml | 0 .../release-stable-all.yml | 0 .../release-webhook.yml | 0 .../ruff.yml | 0 .../stable-release.yml | 0 .../stale-issues.yml | 0 .../test-build.yml | 0 .../test-ci.yml | 0 .../test-execution.yml | 0 .../test-launch.yml | 0 .../test-unit.yml | 0 .../update-api-stubs.yml | 0 .../update-version.yml | 0 .../windows_release_dependencies.yml | 0 .../windows_release_dependencies_manual.yml | 0 .../windows_release_nightly_pytorch.yml | 0 .../windows_release_package.yml | 0 README.md | 7 ++++ utils/socket_activation/README.md | 40 +++++++++++++++++++ utils/socket_activation/comfy.container | 24 +++++++++++ utils/socket_activation/comfy.socket | 8 ++++ utils/socket_activation/comfy2.container | 24 +++++++++++ utils/socket_activation/comfy2.socket | 8 ++++ 25 files changed, 111 insertions(+) rename .github/{workflows => disabled_workflows}/api-node-template.yml (100%) rename .github/{workflows => disabled_workflows}/check-line-endings.yml (100%) rename .github/{workflows => disabled_workflows}/pullrequest-ci-run.yml (100%) rename .github/{workflows => disabled_workflows}/release-stable-all.yml (100%) rename .github/{workflows => disabled_workflows}/release-webhook.yml (100%) rename .github/{workflows => disabled_workflows}/ruff.yml (100%) rename .github/{workflows => disabled_workflows}/stable-release.yml (100%) rename .github/{workflows => disabled_workflows}/stale-issues.yml (100%) rename .github/{workflows => disabled_workflows}/test-build.yml (100%) rename .github/{workflows => disabled_workflows}/test-ci.yml (100%) rename .github/{workflows => disabled_workflows}/test-execution.yml (100%) rename .github/{workflows => disabled_workflows}/test-launch.yml (100%) rename .github/{workflows => disabled_workflows}/test-unit.yml (100%) rename .github/{workflows => disabled_workflows}/update-api-stubs.yml (100%) rename .github/{workflows => disabled_workflows}/update-version.yml (100%) rename .github/{workflows => disabled_workflows}/windows_release_dependencies.yml (100%) rename .github/{workflows => disabled_workflows}/windows_release_dependencies_manual.yml (100%) rename .github/{workflows => disabled_workflows}/windows_release_nightly_pytorch.yml (100%) rename .github/{workflows => disabled_workflows}/windows_release_package.yml (100%) create mode 100644 utils/socket_activation/README.md create mode 100644 utils/socket_activation/comfy.container create mode 100644 utils/socket_activation/comfy.socket create mode 100644 utils/socket_activation/comfy2.container create mode 100644 utils/socket_activation/comfy2.socket diff --git a/.github/workflows/api-node-template.yml b/.github/disabled_workflows/api-node-template.yml similarity index 100% rename from .github/workflows/api-node-template.yml rename to .github/disabled_workflows/api-node-template.yml diff --git a/.github/workflows/check-line-endings.yml b/.github/disabled_workflows/check-line-endings.yml similarity index 100% rename from .github/workflows/check-line-endings.yml rename to .github/disabled_workflows/check-line-endings.yml diff --git a/.github/workflows/pullrequest-ci-run.yml b/.github/disabled_workflows/pullrequest-ci-run.yml similarity index 100% rename from .github/workflows/pullrequest-ci-run.yml rename to .github/disabled_workflows/pullrequest-ci-run.yml diff --git a/.github/workflows/release-stable-all.yml b/.github/disabled_workflows/release-stable-all.yml similarity index 100% rename from .github/workflows/release-stable-all.yml rename to .github/disabled_workflows/release-stable-all.yml diff --git a/.github/workflows/release-webhook.yml b/.github/disabled_workflows/release-webhook.yml similarity index 100% rename from .github/workflows/release-webhook.yml rename to .github/disabled_workflows/release-webhook.yml diff --git a/.github/workflows/ruff.yml b/.github/disabled_workflows/ruff.yml similarity index 100% rename from .github/workflows/ruff.yml rename to .github/disabled_workflows/ruff.yml diff --git a/.github/workflows/stable-release.yml b/.github/disabled_workflows/stable-release.yml similarity index 100% rename from .github/workflows/stable-release.yml rename to .github/disabled_workflows/stable-release.yml diff --git a/.github/workflows/stale-issues.yml b/.github/disabled_workflows/stale-issues.yml similarity index 100% rename from .github/workflows/stale-issues.yml rename to .github/disabled_workflows/stale-issues.yml diff --git a/.github/workflows/test-build.yml b/.github/disabled_workflows/test-build.yml similarity index 100% rename from .github/workflows/test-build.yml rename to .github/disabled_workflows/test-build.yml diff --git a/.github/workflows/test-ci.yml b/.github/disabled_workflows/test-ci.yml similarity index 100% rename from .github/workflows/test-ci.yml rename to .github/disabled_workflows/test-ci.yml diff --git a/.github/workflows/test-execution.yml b/.github/disabled_workflows/test-execution.yml similarity index 100% rename from .github/workflows/test-execution.yml rename to .github/disabled_workflows/test-execution.yml diff --git a/.github/workflows/test-launch.yml b/.github/disabled_workflows/test-launch.yml similarity index 100% rename from .github/workflows/test-launch.yml rename to .github/disabled_workflows/test-launch.yml diff --git a/.github/workflows/test-unit.yml b/.github/disabled_workflows/test-unit.yml similarity index 100% rename from .github/workflows/test-unit.yml rename to .github/disabled_workflows/test-unit.yml diff --git a/.github/workflows/update-api-stubs.yml b/.github/disabled_workflows/update-api-stubs.yml similarity index 100% rename from .github/workflows/update-api-stubs.yml rename to .github/disabled_workflows/update-api-stubs.yml diff --git a/.github/workflows/update-version.yml b/.github/disabled_workflows/update-version.yml similarity index 100% rename from .github/workflows/update-version.yml rename to .github/disabled_workflows/update-version.yml diff --git a/.github/workflows/windows_release_dependencies.yml b/.github/disabled_workflows/windows_release_dependencies.yml similarity index 100% rename from .github/workflows/windows_release_dependencies.yml rename to .github/disabled_workflows/windows_release_dependencies.yml diff --git a/.github/workflows/windows_release_dependencies_manual.yml b/.github/disabled_workflows/windows_release_dependencies_manual.yml similarity index 100% rename from .github/workflows/windows_release_dependencies_manual.yml rename to .github/disabled_workflows/windows_release_dependencies_manual.yml diff --git a/.github/workflows/windows_release_nightly_pytorch.yml b/.github/disabled_workflows/windows_release_nightly_pytorch.yml similarity index 100% rename from .github/workflows/windows_release_nightly_pytorch.yml rename to .github/disabled_workflows/windows_release_nightly_pytorch.yml diff --git a/.github/workflows/windows_release_package.yml b/.github/disabled_workflows/windows_release_package.yml similarity index 100% rename from .github/workflows/windows_release_package.yml rename to .github/disabled_workflows/windows_release_package.yml diff --git a/README.md b/README.md index 91fb510e..9c22eccb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +# Fork of comfy UI adding systemd socket activation support and a ROCM docker file + +**The socket activation support is the result of vibe coding and not sufficiently validated tobe ready for general usage or contributing back upstream. Use at your own risk!** + +Instructions for socket activation in [utils/socket_activation](utils/socket_activation/README.md). +Original readme starts below: +
# ComfyUI diff --git a/utils/socket_activation/README.md b/utils/socket_activation/README.md new file mode 100644 index 00000000..7fcdc218 --- /dev/null +++ b/utils/socket_activation/README.md @@ -0,0 +1,40 @@ +# Rootless podman container with Systemd Socket activation + +## Idea +By passing in the socket from systemd we minimize resource use when not in use. +Since no other network access is required for operation, we can configure the container +with network=none and minimize the risk of the AI escaping. + +## Set up + +Optional, if you want to run this as a separate user +``` +sudo useradd comfy +sudo machinectl shell comfy@ +``` + +Check out this repository, navigate to its root directory and build the comfy +container with +``` +podman build -t localhost/comfy:latest . +``` + +Place comfy.socket in ` ~/.config/systemd/user`, adjust ports and interfaces if needed. +Place comfy.container in `~/.config/containers/systemd`. Adjust paths for models and config if desired. +The files are in `utils/socket_activation`, next to this readme. + +Put model files into the models directory (`~/models`). + +Start the socket: +``` +systemctl --user daemon-reload +systemctl --user enable --now comfy.socket +``` + +If you want to run the service also when the user is not logged in, enable lingering: +``` +sudo loginctl enable-linger +``` + +Check that you can access comfy in browser. For troubleshooting, use, e. g., `journalctl -xe`. + diff --git a/utils/socket_activation/comfy.container b/utils/socket_activation/comfy.container new file mode 100644 index 00000000..c59b9b17 --- /dev/null +++ b/utils/socket_activation/comfy.container @@ -0,0 +1,24 @@ +[Unit] +Description=Comfy ui in a ROCM container +After=network-online.target +Wants=network-online.target + +[Container] +Image=localhost/comfy:latest +#AutoRemove=yes +#PublishPort=8080:8080 +Environment=ROCR_VISIBLE_DEVICES="GGPU-3b0c81617337ec1b" +Network=none +Volume=%h/comfy/models:/comfyui/models:ro,z +Volume=%h/comfy/input:/comfyui/input:Z +Volume=%h/comfy/output:/comfyui/output:Z +Volume=%h/comfy/user:/comfyui/user:Z +AddDevice=/dev/dri +AddDevice=/dev/kfd +Exec= + +#[Service] +#Restart=always + +[Install] +WantedBy=default.target diff --git a/utils/socket_activation/comfy.socket b/utils/socket_activation/comfy.socket new file mode 100644 index 00000000..e7e0875f --- /dev/null +++ b/utils/socket_activation/comfy.socket @@ -0,0 +1,8 @@ +[Unit] +Description=llama socket + +[Socket] +ListenStream=0.0.0.0:8095 + +[Install] +WantedBy=default.target diff --git a/utils/socket_activation/comfy2.container b/utils/socket_activation/comfy2.container new file mode 100644 index 00000000..8be303e0 --- /dev/null +++ b/utils/socket_activation/comfy2.container @@ -0,0 +1,24 @@ +[Unit] +Description=Comfy ui in a ROCM container +After=network-online.target +Wants=network-online.target + +[Container] +Image=localhost/comfy:latest +#AutoRemove=yes +#PublishPort=8080:8080 +Network=none +Environment=ROCR_VISIBLE_DEVICES="GPU-3ce290c173497dfb" +Volume=%h/comfy/models:/comfyui/models:ro,z +Volume=%h/comfy/input2:/comfyui/input:Z +Volume=%h/comfy/output2:/comfyui/output:Z +Volume=%h/comfy/user2:/comfyui/user:Z +AddDevice=/dev/dri +AddDevice=/dev/kfd +Exec= + +#[Service] +#Restart=always + +[Install] +WantedBy=default.target diff --git a/utils/socket_activation/comfy2.socket b/utils/socket_activation/comfy2.socket new file mode 100644 index 00000000..6cfd8301 --- /dev/null +++ b/utils/socket_activation/comfy2.socket @@ -0,0 +1,8 @@ +[Unit] +Description=Comfy second instance socket + +[Socket] +ListenStream=0.0.0.0:8096 + +[Install] +WantedBy=default.target