bug fix in n8n deployment
This commit is contained in:
parent
db35838f72
commit
f9e600345f
|
|
@ -3248,59 +3248,74 @@ class CloudManager:
|
||||||
statusWriter.writeToFile(f"Error getting administrator: {str(e)} [404]")
|
statusWriter.writeToFile(f"Error getting administrator: {str(e)} [404]")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Step 1: Create the website
|
# Step 1: Check if website already exists, create only if not
|
||||||
statusWriter.writeToFile('Creating website...,10')
|
existing_website = Websites.objects.filter(domain=domain_name).first()
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Creating website for {domain_name}")
|
|
||||||
wm = WebsiteManager()
|
if existing_website:
|
||||||
result = wm.submitWebsiteCreation(admin.pk, website_data)
|
# Website already exists, skip creation
|
||||||
result_data = json.loads(result.content)
|
logging.writeToFile(f"[_install_n8n_with_website] Website {domain_name} already exists, skipping creation")
|
||||||
|
statusWriter.writeToFile(f'Website already exists, proceeding to N8N deployment...,20')
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Website creation result: {result_data}")
|
website = existing_website
|
||||||
|
else:
|
||||||
if result_data.get('createWebSiteStatus', 0) != 1:
|
# Website doesn't exist, create it
|
||||||
statusWriter.writeToFile(f"Failed to create website: {result_data.get('error_message', 'Unknown error')} [404]")
|
statusWriter.writeToFile('Creating website...,10')
|
||||||
return
|
logging.writeToFile(f"[_install_n8n_with_website] Creating website for {domain_name}")
|
||||||
|
wm = WebsiteManager()
|
||||||
# Wait for website creation to complete - no time limit
|
result = wm.submitWebsiteCreation(admin.pk, website_data)
|
||||||
creation_status_path = result_data.get('tempStatusPath')
|
result_data = json.loads(result.content)
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Website creation status path: {creation_status_path}")
|
|
||||||
|
logging.writeToFile(f"[_install_n8n_with_website] Website creation result: {result_data}")
|
||||||
if creation_status_path:
|
|
||||||
statusWriter.writeToFile('Waiting for website creation to complete (including SSL)...,15')
|
if result_data.get('createWebSiteStatus', 0) != 1:
|
||||||
check_count = 0
|
statusWriter.writeToFile(f"Failed to create website: {result_data.get('error_message', 'Unknown error')} [404]")
|
||||||
while True:
|
return
|
||||||
try:
|
|
||||||
with open(creation_status_path, 'r') as f:
|
# Wait for website creation to complete - 10 minute timeout
|
||||||
status = f.read()
|
creation_status_path = result_data.get('tempStatusPath')
|
||||||
if '[200]' in status:
|
logging.writeToFile(f"[_install_n8n_with_website] Website creation status path: {creation_status_path}")
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Website creation completed successfully")
|
|
||||||
break
|
if creation_status_path:
|
||||||
elif '[404]' in status:
|
statusWriter.writeToFile('Waiting for website creation to complete (including SSL)...,15')
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Website creation failed: {status}")
|
check_count = 0
|
||||||
statusWriter.writeToFile(f"Website creation failed: {status} [404]")
|
max_checks = 600 # 10 minute timeout (600 seconds)
|
||||||
return
|
while check_count < max_checks:
|
||||||
except Exception as e:
|
try:
|
||||||
if check_count % 10 == 0: # Log every 10 checks
|
with open(creation_status_path, 'r') as f:
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Still waiting for website creation... (check #{check_count})")
|
status = f.read()
|
||||||
|
if '[200]' in status:
|
||||||
check_count += 1
|
logging.writeToFile(f"[_install_n8n_with_website] Website creation completed successfully")
|
||||||
time.sleep(1)
|
break
|
||||||
|
elif '[404]' in status:
|
||||||
# Get the created website object
|
logging.writeToFile(f"[_install_n8n_with_website] Website creation failed: {status}")
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Getting website object for {domain_name}")
|
statusWriter.writeToFile(f"Website creation failed: {status} [404]")
|
||||||
try:
|
return
|
||||||
website = Websites.objects.get(domain=domain_name)
|
except Exception as e:
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Found website object: {website.domain}")
|
if check_count % 10 == 0: # Log every 10 checks
|
||||||
except Websites.DoesNotExist:
|
logging.writeToFile(f"[_install_n8n_with_website] Still waiting for website creation... (check #{check_count})")
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Website object not found for {domain_name}")
|
|
||||||
statusWriter.writeToFile('Website creation succeeded but website object not found [404]')
|
check_count += 1
|
||||||
return
|
time.sleep(1)
|
||||||
except Exception as e:
|
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Error getting website object: {str(e)}")
|
if check_count >= max_checks:
|
||||||
statusWriter.writeToFile(f'Error getting website object: {str(e)} [404]')
|
logging.writeToFile(f"[_install_n8n_with_website] Website creation timed out after 10 minutes")
|
||||||
return
|
statusWriter.writeToFile(f"Website creation timed out after 10 minutes [404]")
|
||||||
|
return
|
||||||
statusWriter.writeToFile('Website created successfully...,20')
|
|
||||||
|
# Get the created website object
|
||||||
|
logging.writeToFile(f"[_install_n8n_with_website] Getting website object for {domain_name}")
|
||||||
|
try:
|
||||||
|
website = Websites.objects.get(domain=domain_name)
|
||||||
|
logging.writeToFile(f"[_install_n8n_with_website] Found website object: {website.domain}")
|
||||||
|
except Websites.DoesNotExist:
|
||||||
|
logging.writeToFile(f"[_install_n8n_with_website] Website object not found for {domain_name}")
|
||||||
|
statusWriter.writeToFile('Website creation succeeded but website object not found [404]')
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
logging.writeToFile(f"[_install_n8n_with_website] Error getting website object: {str(e)}")
|
||||||
|
statusWriter.writeToFile(f'Error getting website object: {str(e)} [404]')
|
||||||
|
return
|
||||||
|
|
||||||
|
statusWriter.writeToFile('Website created successfully...,20')
|
||||||
logging.writeToFile(f"[_install_n8n_with_website] Website creation phase complete")
|
logging.writeToFile(f"[_install_n8n_with_website] Website creation phase complete")
|
||||||
|
|
||||||
# Step 2: Create database using native CyberPanel process
|
# Step 2: Create database using native CyberPanel process
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue