Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0ece85d
initial commit for comfystream api
ad-astra-video Feb 6, 2025
465fec4
add GitPython to requirements.txt
ad-astra-video Feb 6, 2025
e42cc31
Add nodes, models and settings api
ad-astra-video Feb 8, 2025
bd42ec5
install nodes in conda environments
ad-astra-video Feb 8, 2025
9d8e95b
fixes for models download and nodes listing
ad-astra-video Feb 13, 2025
020b9d9
reload embedded client
ad-astra-video Feb 13, 2025
1171ae7
update to install in one env
ad-astra-video Mar 12, 2025
678429e
move adding mgmt api routes before route prefix
ad-astra-video Mar 13, 2025
e5d99a6
update reload pipeline
ad-astra-video Mar 13, 2025
0988908
reset webrtc connections on reload
ad-astra-video Mar 14, 2025
98f5a6c
cleanup
ad-astra-video Mar 14, 2025
5d46936
cleanup
ad-astra-video Mar 17, 2025
79b10c6
update routes
ad-astra-video Mar 17, 2025
c0c3a92
update set twilio account info
ad-astra-video Mar 18, 2025
0c5a05c
cleanup
ad-astra-video Mar 18, 2025
1adc535
cleanup
ad-astra-video Mar 18, 2025
4cb6b67
route update and log lines updates
ad-astra-video Mar 18, 2025
5825c82
add enable/disable and restart comfyui
ad-astra-video Mar 29, 2025
04b07fa
add restart comfyui to comfystream menu
ad-astra-video Mar 29, 2025
0ed2303
add mgmt api UI to ComfyStream menu in ComfyUI, some fixes/improvements
ad-astra-video Apr 7, 2025
3fc8196
add mgmt of TURN server credentials
ad-astra-video Apr 14, 2025
7d2a4b1
fix update node
ad-astra-video Apr 18, 2025
d3993eb
add log lines on ComfyUI restart
ad-astra-video Apr 27, 2025
cca6715
fix dependencies and update import
ad-astra-video May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions nodes/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import aiohttp
from ..server_manager import LocalComfyStreamServer
from .. import settings_storage
import subprocess

routes = None
server_manager = None
Expand Down Expand Up @@ -215,3 +216,45 @@ async def manage_configuration(request):
logging.error(f"Error managing configuration: {str(e)}")
return web.json_response({"error": str(e)}, status=500)

@routes.post('/comfystream/settings/manage')
async def manage_comfystream(request):
"""Manage ComfyStream server settings"""
#check if server is running
server_status = server_manager.get_status()
if not server_status["running"]:
return web.json_response({"error": "ComfyStream Server is not running"}, status=503)

try:
data = await request.json()
action_type = data.get("action_type")
action = data.get("action")
payload = data.get("payload")
url_host = server_status.get("host", "localhost")
url_port = server_status.get("port", "8889")
mgmt_url = f"http://{url_host}:{url_port}/settings/{action_type}/{action}"

async with aiohttp.ClientSession() as session:
async with session.post(
mgmt_url,
json=payload,
headers={"Content-Type": "application/json"}
) as response:
if not response.ok:
return web.json_response(
{"error": f"Server error: {response.status}"},
status=response.status
)
return web.json_response(await response.json())
except Exception as e:
logging.error(f"Error managing ComfyStream: {str(e)}")
return web.json_response({"error": str(e)}, status=500)

@routes.post('/comfyui/restart')
async def manage_configuration(request):
server_status = server_manager.get_status()
if server_status["running"]:
await server_manager.stop()
logging.info("Restarting ComfyUI...")
subprocess.run(["supervisorctl", "restart", "comfyui"])
logging.info("Restarting ComfyUI...in process")
return web.json_response({"success": True}, status=200)
44 changes: 43 additions & 1 deletion nodes/web/js/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,38 @@ document.addEventListener('comfy-extension-registered', (event) => {
}
});

async function restartComfyUI() {
try {
const response = await fetch('/comfyui/restart', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: "" // No body needed
});

if (!response.ok) {
const errorText = await response.text();
console.error("[ComfyStream] ComfyUI restart returned error response:", response.status, errorText);
try {
const errorData = JSON.parse(errorText);
throw new Error(errorData.error || `Server error: ${response.status}`);
} catch (e) {
throw new Error(`Server error: ${response.status} - ${errorText}`);
}
}

const data = await response.json();

return data;
} catch (error) {
console.error('[ComfyStream] Error restarting ComfyUI:', error);
app.ui.dialog.show('Error', error.message || 'Failed to restart ComfyUI');
throw error;
}
}

async function controlServer(action) {
try {
// Get settings from the settings manager
Expand Down Expand Up @@ -256,6 +288,12 @@ const extension = {
icon: "pi pi-cog",
label: "Server Settings",
function: openSettings
},
{
id: "ComfyStream.RestartComfyUI",
icon: "pi pi-refresh",
label: "Restart ComfyUI",
function: restartComfyUI
}
],

Expand All @@ -270,7 +308,9 @@ const extension = {
"ComfyStream.StopServer",
"ComfyStream.RestartServer",
null, // Separator
"ComfyStream.Settings"
"ComfyStream.Settings",
null, // Separator
"ComfyStream.RestartComfyUI"
]
}
],
Expand Down Expand Up @@ -300,6 +340,8 @@ const extension = {
comfyStreamMenu.addItem("Restart Server", () => controlServer('restart'), { icon: "pi pi-refresh" });
comfyStreamMenu.addSeparator();
comfyStreamMenu.addItem("Server Settings", openSettings, { icon: "pi pi-cog" });
comfyStreamMenu.addSeparator();
comfyStreamMenu.addItem("Restart ComfyUI", () => restartComfyUI(), { icon: "pi pi-refresh" });
}
// New menu system is handled automatically by the menuCommands registration

Expand Down
Loading