fix: ensure logs are disabled by default
This commit is contained in:
		
							parent
							
								
									81bde40aeb
								
							
						
					
					
						commit
						2193dd287d
					
				@ -26,6 +26,7 @@ import threading
 | 
			
		||||
api = None
 | 
			
		||||
api_task = None
 | 
			
		||||
prompt_metadata = {}
 | 
			
		||||
cd_enable_log = os.environ.get('CD_ENABLE_LOG', 'false').lower() == 'true'
 | 
			
		||||
 | 
			
		||||
def post_prompt(json_data):
 | 
			
		||||
    prompt_server = server.PromptServer.instance
 | 
			
		||||
@ -157,6 +158,8 @@ async def websocket_handler(request):
 | 
			
		||||
    try:
 | 
			
		||||
        # Send initial state to the new client
 | 
			
		||||
        await send("status", { 'sid': sid }, sid)
 | 
			
		||||
 | 
			
		||||
        if cd_enable_log:
 | 
			
		||||
            await send_first_time_log(sid)
 | 
			
		||||
            
 | 
			
		||||
        async for msg in ws:
 | 
			
		||||
@ -480,4 +483,5 @@ def run_in_new_thread(coroutine):
 | 
			
		||||
    t.start()
 | 
			
		||||
    asyncio.run_coroutine_threadsafe(coroutine, new_loop)
 | 
			
		||||
 | 
			
		||||
if cd_enable_log:
 | 
			
		||||
    run_in_new_thread(watch_file_changes(log_file_path, send_logs_to_websocket))
 | 
			
		||||
 | 
			
		||||
@ -7,6 +7,13 @@ import threading
 | 
			
		||||
import logging
 | 
			
		||||
from logging.handlers import RotatingFileHandler
 | 
			
		||||
 | 
			
		||||
# Running with export CD_ENABLE_LOG=true; python main.py
 | 
			
		||||
 | 
			
		||||
# Check for 'cd-enable-log' flag in input arguments
 | 
			
		||||
# cd_enable_log = '--cd-enable-log' in sys.argv
 | 
			
		||||
cd_enable_log = os.environ.get('CD_ENABLE_LOG', 'false').lower() == 'true'
 | 
			
		||||
 | 
			
		||||
def setup():
 | 
			
		||||
    handler = RotatingFileHandler('comfy-deploy.log', maxBytes=500000, backupCount=5)
 | 
			
		||||
 | 
			
		||||
    original_stdout = sys.stdout
 | 
			
		||||
@ -47,6 +54,10 @@ class StreamToLogger():
 | 
			
		||||
    sys.stdout = StreamToLogger(logging.INFO)
 | 
			
		||||
    sys.stderr = StreamToLogger(logging.ERROR)
 | 
			
		||||
 | 
			
		||||
if cd_enable_log:
 | 
			
		||||
   print("** Comfy Deploy logging enabled")
 | 
			
		||||
   setup() 
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    # Get the absolute path of the script's directory
 | 
			
		||||
    script_dir = os.path.dirname(os.path.abspath(__file__))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user