mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-09-27 20:24:54 +02:00
* Add django debug toolbar * Remove duplicate debug toolbar URLs * Remove orphaned import in startScan * Add DEBUG config commented in entrypoint * Install debug toolbar into celery beat * Create dev docker compose & entrypoints * Move django toolbar install to dev entrypoints * Install debug_toolbar only when debug env var is set * Add dev command to MakeFile * Use DEBUG from settings.py exclusively * Add remote debug configuration in dev env * Add VSCode debug configuration * Celery log level to 1 when debug is on * Remove hard coded celery debug port * Add gunicorn in the production setup * Add export var for celery log level * Restrict debug port to 127.0.0.1 * Set remote debug to false by default * Update doc on debug step for submitting issue * Create dev docker compose & entrypoints * Add django debug toolbar * Remove duplicate debug toolbar URLs * Remove orphaned import in startScan * Add DEBUG config commented in entrypoint * Install debug toolbar into celery beat * Move django toolbar install to dev entrypoints * Install debug_toolbar only when debug env var is set * Add dev command to MakeFile * Use DEBUG from settings.py exclusively * Add remote debug configuration in dev env * Add VSCode debug configuration * Celery log level to 1 when debug is on * Remove hard coded celery debug port * Add gunicorn in the production setup * Add export var for celery log level * Restrict debug port to 127.0.0.1 * Set remote debug to false by default * Update doc on debug step for submitting issue --------- Co-authored-by: Raynald <raynald@easi-services.fr> Co-authored-by: Psyray <psyray@users.noreply.github.com>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import os
|
|
import socket
|
|
from reNgine.settings import REMOTE_DEBUG_PORT
|
|
|
|
def is_port_in_use(port, host='127.0.0.1'):
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
try:
|
|
s.bind((host, port))
|
|
return False
|
|
except OSError:
|
|
return True
|
|
|
|
def setup_debugger(wait=False, gevent='False'):
|
|
import debugpy
|
|
if REMOTE_DEBUG_PORT > 0:
|
|
# Prevent to set breakpoitn in VSCode - https://stackoverflow.com/a/66714620
|
|
# But seems to be needed while debugging workers
|
|
os.environ['GEVENT_SUPPORT'] = gevent
|
|
if not is_port_in_use(REMOTE_DEBUG_PORT):
|
|
try:
|
|
debugpy.listen(('127.0.0.1', REMOTE_DEBUG_PORT))
|
|
print(f"\n⚡ Debugger started on port "+ str(REMOTE_DEBUG_PORT) +" ⚡\n")
|
|
if wait:
|
|
debugpy.wait_for_client()
|
|
except Exception as e:
|
|
print(f"Failed to start debugger: {e}")
|
|
else:
|
|
print(f"\n⚠️ Debugger already started on port "+ str(REMOTE_DEBUG_PORT) +" ⚠️\n")
|
|
|