Skip to content

Commit 9cb619c

Browse files
committed
Incorporating @ptrovatelli's suggestions.
1 parent f9acd66 commit 9cb619c

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

docker-compose.override.ptvsd.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ services:
1212
published: 3000
1313
protocol: tcp
1414
mode: host
15-
- target: 8000
16-
published: 8000
17-
protocol: tcp
18-
mode: host
1915
celeryworker:
2016
volumes:
2117
- '.:/app:z'

docker/entrypoint-uwsgi-ptvsd.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ if [ ! -f ${TARGET_SETTINGS_FILE} ]; then
1212
cp dojo/settings/settings.dist.py dojo/settings/settings.py
1313
fi
1414

15-
PORT=8000
16-
echo "Serving directly on port ${PORT}"
17-
python manage.py runserver 0.0.0.0:${PORT} --noreload --nothreading
18-
19-
#exec uwsgi \
20-
# "--${DD_UWSGI_MODE}" "${DD_UWSGI_ENDPOINT}" \
21-
# --protocol uwsgi \
22-
# --wsgi dojo.wsgi:application \
23-
# --py-autoreload 1
15+
exec uwsgi \
16+
"--${DD_UWSGI_MODE}" "${DD_UWSGI_ENDPOINT}" \
17+
--protocol uwsgi \
18+
--wsgi dojo.wsgi:application \
19+
--py-autoreload 1 \
20+
--enable-threads --lazy-apps --honour-stdin
21+

dojo/wsgi.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
1515
"""
1616
import os
17+
import socket
18+
from socket import error as socket_error
1719

1820
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
1921
# if running multiple sites in the same mod_wsgi process. To fix this, use
@@ -31,3 +33,23 @@
3133
# Apply WSGI middleware here.
3234
# from helloworld.wsgi import HelloWorldApplication
3335
# application = HelloWorldApplication(application)
36+
37+
def _check_ptvsd_port_not_in_use(port):
38+
try:
39+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
40+
sock.bind(('127.0.0.1', port))
41+
except socket_error as se:
42+
return False
43+
44+
return True
45+
46+
47+
ptvsd_port = 3000
48+
if os.environ.get("DD_DEBUG") == "on" and _check_ptvsd_port_not_in_use(ptvsd_port):
49+
try:
50+
# enable remote debugging
51+
import ptvsd
52+
ptvsd.enable_attach(address=('0.0.0.0', ptvsd_port))
53+
print("ptvsd listening on port " + ptvsd_port)
54+
except Exception as e:
55+
print("Generic exception caught with DD_DEBUG on. Passing.")

manage.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
#!/usr/bin/env python
22
import os
33
import sys
4-
import socket
5-
from socket import error as socket_error
64

75

86
if __name__ == "__main__":
97
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dojo.settings.settings")
108

119
from django.core.management import execute_from_command_line
1210

13-
def _check_ptvsd_port_not_in_use(port):
14-
try:
15-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
16-
sock.bind(('127.0.0.1', port))
17-
except socket_error as se:
18-
return False
19-
20-
return True
21-
22-
ptvsd_port = 3000
23-
if os.environ.get("DD_DEBUG") == "on" and _check_ptvsd_port_not_in_use(ptvsd_port):
24-
try:
25-
# enable remote debugging
26-
import ptvsd
27-
ptvsd.enable_attach(address=('0.0.0.0', ptvsd_port))
28-
except Exception as e:
29-
print("Generic exception caught with DD_DEBUG on. Passing.")
3011
execute_from_command_line(sys.argv)

0 commit comments

Comments
 (0)