kopia lustrzana https://github.com/OpenDroneMap/WebODM
Added gunicorn, nginx, modified code to build static assets, check debug settings, apscheduler sync
rodzic
b67d3ec0a5
commit
197a993d9e
|
@ -26,8 +26,8 @@ RUN printf "Package: *\nPin: release a=testing\nPin-Priority: 750\n" > /etc/apt/
|
||||||
RUN printf "deb http://mirror.steadfast.net/debian/ stable main contrib non-free\ndeb-src http://mirror.steadfast.net/debian/ stable main contrib non-free" > /etc/apt/sources.list.d/stable.list
|
RUN printf "deb http://mirror.steadfast.net/debian/ stable main contrib non-free\ndeb-src http://mirror.steadfast.net/debian/ stable main contrib non-free" > /etc/apt/sources.list.d/stable.list
|
||||||
RUN printf "deb http://mirror.steadfast.net/debian/ testing main contrib non-free\ndeb-src http://mirror.steadfast.net/debian/ testing main contrib non-free" > /etc/apt/sources.list.d/testing.list
|
RUN printf "deb http://mirror.steadfast.net/debian/ testing main contrib non-free\ndeb-src http://mirror.steadfast.net/debian/ testing main contrib non-free" > /etc/apt/sources.list.d/testing.list
|
||||||
|
|
||||||
# Install GDAL
|
# Install GDAL, nginx
|
||||||
RUN apt-get update && apt-get install -t testing -y binutils libproj-dev gdal-bin
|
RUN apt-get update && apt-get install -t testing -y binutils libproj-dev gdal-bin nginx
|
||||||
|
|
||||||
WORKDIR /webodm/nodeodm/external/node-OpenDroneMap
|
WORKDIR /webodm/nodeodm/external/node-OpenDroneMap
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
14
app/boot.py
14
app/boot.py
|
@ -6,14 +6,24 @@ from django.db.utils import ProgrammingError
|
||||||
from guardian.shortcuts import assign_perm
|
from guardian.shortcuts import assign_perm
|
||||||
|
|
||||||
from nodeodm.models import ProcessingNode
|
from nodeodm.models import ProcessingNode
|
||||||
from . import signals, scheduler
|
from . import scheduler
|
||||||
import logging, os
|
import logging
|
||||||
from .models import Task
|
from .models import Task
|
||||||
from webodm import settings
|
from webodm import settings
|
||||||
|
from webodm.wsgi import booted
|
||||||
|
|
||||||
|
|
||||||
def boot():
|
def boot():
|
||||||
|
# booted is a shared memory variable to keep track of boot status
|
||||||
|
# as multiple workers could trigger the boot sequence twice
|
||||||
|
if booted.value: return
|
||||||
|
|
||||||
|
booted.value = True
|
||||||
logger = logging.getLogger('app.logger')
|
logger = logging.getLogger('app.logger')
|
||||||
|
logger.info("Booting...")
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
logger.warning("Debug mode is ON (for development this is OK)")
|
||||||
|
|
||||||
# Check default group
|
# Check default group
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
*
|
|
@ -0,0 +1,66 @@
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
# Change this if running outside docker!
|
||||||
|
user root root;
|
||||||
|
pid /tmp/nginx.pid;
|
||||||
|
error_log /tmp/nginx.error.log;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024; # increase if you have lots of clients
|
||||||
|
accept_mutex off; # set to 'on' if nginx worker_processes > 1
|
||||||
|
use epoll;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
|
# fallback in case we can't determine a type
|
||||||
|
default_type application/octet-stream;
|
||||||
|
access_log /tmp/nginx.access.log combined;
|
||||||
|
sendfile on;
|
||||||
|
|
||||||
|
upstream app_server {
|
||||||
|
# fail_timeout=0 means we always retry an upstream even if it failed
|
||||||
|
# to return a good HTTP response
|
||||||
|
|
||||||
|
# for UNIX domain socket setups
|
||||||
|
server unix:/tmp/gunicorn.sock fail_timeout=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 8000 deferred;
|
||||||
|
client_max_body_size 20G;
|
||||||
|
|
||||||
|
# set the correct host(s) for your site
|
||||||
|
server_name webodm.localhost;
|
||||||
|
|
||||||
|
keepalive_timeout 5;
|
||||||
|
|
||||||
|
# path for static files
|
||||||
|
location /static {
|
||||||
|
root /webodm/build;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
# CORS settings
|
||||||
|
|
||||||
|
# These settings are VERY permissive, consider tightening them
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
||||||
|
# enable this if and only if you use HTTPS
|
||||||
|
# proxy_set_header X-Forwarded-Proto https;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
|
||||||
|
# we don't want nginx trying to do something clever with
|
||||||
|
# redirects, we set the Host: header above already.
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_pass http://app_server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ appdirs==1.4.0
|
||||||
APScheduler==3.2.0
|
APScheduler==3.2.0
|
||||||
coreapi==2.0.9
|
coreapi==2.0.9
|
||||||
Django==1.10.5
|
Django==1.10.5
|
||||||
|
django-cors-headers==2.0.2
|
||||||
django-debug-toolbar==1.6
|
django-debug-toolbar==1.6
|
||||||
django-filter==0.15.3
|
django-filter==0.15.3
|
||||||
django-guardian==1.4.6
|
django-guardian==1.4.6
|
||||||
|
@ -12,6 +13,7 @@ djangorestframework-jwt==1.9.0
|
||||||
drf-nested-routers==0.11.1
|
drf-nested-routers==0.11.1
|
||||||
funcsigs==1.0.2
|
funcsigs==1.0.2
|
||||||
futures==3.0.5
|
futures==3.0.5
|
||||||
|
gunicorn==19.7.1
|
||||||
itypes==1.1.0
|
itypes==1.1.0
|
||||||
Markdown==2.6.7
|
Markdown==2.6.7
|
||||||
openapi-codec==1.1.7
|
openapi-codec==1.1.7
|
||||||
|
@ -31,4 +33,3 @@ strict-rfc3339==0.7
|
||||||
tzlocal==1.3
|
tzlocal==1.3
|
||||||
uritemplate==3.0.0
|
uritemplate==3.0.0
|
||||||
webcolors==1.5
|
webcolors==1.5
|
||||||
django-cors-headers==2.0.2
|
|
||||||
|
|
10
start.sh
10
start.sh
|
@ -58,6 +58,9 @@ fi
|
||||||
echo Running migrations
|
echo Running migrations
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
|
|
||||||
|
echo Collecting static assets
|
||||||
|
python manage.py collectstatic --noinput
|
||||||
|
|
||||||
if [[ $1 = "--create-default-pnode" ]]; then
|
if [[ $1 = "--create-default-pnode" ]]; then
|
||||||
echo "from nodeodm.models import ProcessingNode; ProcessingNode.objects.update_or_create(hostname='node-odm-1', defaults={'hostname': 'node-odm-1', 'port': 3000})" | python manage.py shell
|
echo "from nodeodm.models import ProcessingNode; ProcessingNode.objects.update_or_create(hostname='node-odm-1', defaults={'hostname': 'node-odm-1', 'port': 3000})" | python manage.py shell
|
||||||
fi
|
fi
|
||||||
|
@ -73,7 +76,12 @@ echo Open a web browser and navigate to http://localhost:8000
|
||||||
echo -e "\033[39m"
|
echo -e "\033[39m"
|
||||||
echo -e "\033[91mNOTE:\033[39m Windows users using docker should replace localhost with the IP of their docker machine's IP. To find what that is, run: docker-machine ip") &
|
echo -e "\033[91mNOTE:\033[39m Windows users using docker should replace localhost with the IP of their docker machine's IP. To find what that is, run: docker-machine ip") &
|
||||||
|
|
||||||
python manage.py runserver 0.0.0.0:8000
|
if [ $1 = "--setup-devenv" ] || [ $2 = "--setup-devenv" ]; then
|
||||||
|
python manage.py runserver 0.0.0.0:8000
|
||||||
|
else
|
||||||
|
nginx -c /webodm/nginx/nginx.conf
|
||||||
|
gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --preload
|
||||||
|
fi
|
||||||
|
|
||||||
# If this is executed, it means the previous command failed, don't display the congratulations message
|
# If this is executed, it means the previous command failed, don't display the congratulations message
|
||||||
kill %1
|
kill %1
|
||||||
|
|
|
@ -26,7 +26,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
SECRET_KEY = 'gmarsutd!fee6_58=6k)2je#o2^&&)ovu1svjg8k^(a!7qa7r&'
|
SECRET_KEY = 'gmarsutd!fee6_58=6k)2je#o2^&&)ovu1svjg8k^(a!7qa7r&'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
TESTING = sys.argv[1:2] == ['test']
|
||||||
|
DEBUG = sys.argv[1:2] == ['runserver'] or TESTING
|
||||||
INTERNAL_IPS = ['127.0.0.1']
|
INTERNAL_IPS = ['127.0.0.1']
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
@ -142,6 +143,7 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, 'build', 'static')
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, 'app', 'static'),
|
os.path.join(BASE_DIR, 'app', 'static'),
|
||||||
]
|
]
|
||||||
|
@ -239,7 +241,6 @@ JWT_AUTH = {
|
||||||
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
|
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
|
||||||
}
|
}
|
||||||
|
|
||||||
TESTING = sys.argv[1:2] == ['test']
|
|
||||||
if TESTING:
|
if TESTING:
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media_test')
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media_test')
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,11 @@ https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from multiprocessing import Value
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webodm.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webodm.settings")
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
|
||||||
|
booted = Value('b', False)
|
Ładowanie…
Reference in New Issue