From b1f8e15530778f82724091fc5be4177641b28105 Mon Sep 17 00:00:00 2001 From: sinergia <alejandro.ayala@onecluster.org> Date: Thu, 20 Jun 2024 16:28:59 -0500 Subject: [PATCH] Feat(WIP): Producction Mode --- production/entrypoint.sh | 4 ++++ production/nginx.conf | 19 +++++++++++++++++++ production/start.sh | 21 +++++++++++++++++++++ production/trytond.conf | 7 +++++++ production/trytond_cron_logging.conf | 26 ++++++++++++++++++++++++++ production/trytond_logging.conf | 26 ++++++++++++++++++++++++++ production/trytond_worker_logging.conf | 26 ++++++++++++++++++++++++++ production/uwsgi.conf | 9 +++++++++ 8 files changed, 138 insertions(+) create mode 100644 production/entrypoint.sh create mode 100644 production/nginx.conf create mode 100644 production/start.sh create mode 100644 production/trytond.conf create mode 100644 production/trytond_cron_logging.conf create mode 100644 production/trytond_logging.conf create mode 100644 production/trytond_worker_logging.conf create mode 100644 production/uwsgi.conf diff --git a/production/entrypoint.sh b/production/entrypoint.sh new file mode 100644 index 0000000..94ef7de --- /dev/null +++ b/production/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -e + diff --git a/production/nginx.conf b/production/nginx.conf new file mode 100644 index 0000000..9cedd25 --- /dev/null +++ b/production/nginx.conf @@ -0,0 +1,19 @@ +server { + server_name ${SERVER_NAME}; + listen ${NGINX_PORT}; + client_max_body_size 50M; + + sendfile on; + send_timeout 300s; + + location / { + proxy_pass http://tryton:8000/; # "trytond" is the service name of another Docker container on port 8000 + proxy_read_timeout 300; + proxy_connect_timeout 300; + proxy_send_timeout 300; + proxy_set_header Host ${INIT_VAR_NAME}host; + proxy_set_header X-Real-IP ${INIT_VAR_NAME}remote_addr; + proxy_set_header X-Forwarded-For ${INIT_VAR_NAME}proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host ${INIT_VAR_NAME}server_name; + } +} diff --git a/production/start.sh b/production/start.sh new file mode 100644 index 0000000..6b11aa0 --- /dev/null +++ b/production/start.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -s /etc/trytond_populate.conf ]; then + if [ "$DEVELOP" == "True" ]; then + trytond -c /etc/trytond.conf --dev --logconf /etc/trytond_logging.conf + else + uwsgi --ini /etc/uwsgi.conf + fi +else + sleep $SLEEP_TRYTOND_ADMIN && + echo $TRYTONADMINPASS > $TRYTONPASSFILE + if [ "$Provider" == "Kalenis" ]; then + trytond-admin -c /etc/trytond.conf -d $POSTGRES_DB --all --email $EMAIL -u user_view -vv + else + trytond-admin -c /etc/trytond.conf -d $POSTGRES_DB --all --email $EMAIL -vv + fi + echo "1" > /etc/trytond_populate.conf && + /bin/bash /opt/start.sh +fi + + diff --git a/production/trytond.conf b/production/trytond.conf new file mode 100644 index 0000000..ea4b20b --- /dev/null +++ b/production/trytond.conf @@ -0,0 +1,7 @@ +[web] +listen=0.0.0.0:8000 +root=/var/lib/trytond/www + +[database] +list=False +path=/mnt/attachment \ No newline at end of file diff --git a/production/trytond_cron_logging.conf b/production/trytond_cron_logging.conf new file mode 100644 index 0000000..7d5a817 --- /dev/null +++ b/production/trytond_cron_logging.conf @@ -0,0 +1,26 @@ +[formatters] +keys=simple + +[handlers] +keys=rotate,console + +[loggers] +keys=root + +[formatter_simple] +format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s +datefmt=%a %b %d %H:%M:%S %Y + +[handler_rotate] +class=handlers.TimedRotatingFileHandler +args=('/var/log/trytond/trytond_cron.log', 'D', 1, 30) +formatter=simple + +[handler_console] +class=StreamHandler +formatter=simple +args=(sys.stdout,) + +[logger_root] +level=INFO +handlers=rotate,console \ No newline at end of file diff --git a/production/trytond_logging.conf b/production/trytond_logging.conf new file mode 100644 index 0000000..536bb3c --- /dev/null +++ b/production/trytond_logging.conf @@ -0,0 +1,26 @@ +[formatters] +keys=simple + +[handlers] +keys=rotate,console + +[loggers] +keys=root + +[formatter_simple] +format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s +datefmt=%a %b %d %H:%M:%S %Y + +[handler_rotate] +class=handlers.TimedRotatingFileHandler +args=('/var/log/trytond/trytond.log', 'D', 1, 30) +formatter=simple + +[handler_console] +class=StreamHandler +formatter=simple +args=(sys.stdout,) + +[logger_root] +level=INFO +handlers=rotate,console diff --git a/production/trytond_worker_logging.conf b/production/trytond_worker_logging.conf new file mode 100644 index 0000000..4a7a0b1 --- /dev/null +++ b/production/trytond_worker_logging.conf @@ -0,0 +1,26 @@ +[formatters] +keys=simple + +[handlers] +keys=rotate,console + +[loggers] +keys=root + +[formatter_simple] +format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s +datefmt=%a %b %d %H:%M:%S %Y + +[handler_rotate] +class=handlers.TimedRotatingFileHandler +args=('/var/log/trytond/trytond_worker.log', 'D', 1, 30) +formatter=simple + +[handler_console] +class=StreamHandler +formatter=simple +args=(sys.stdout,) + +[logger_root] +level=INFO +handlers=rotate,console \ No newline at end of file diff --git a/production/uwsgi.conf b/production/uwsgi.conf new file mode 100644 index 0000000..e2be8dc --- /dev/null +++ b/production/uwsgi.conf @@ -0,0 +1,9 @@ +[uwsgi] +http-socket=0.0.0.0:8000 +plugins=python3 +env=TRYTOND_CONFIG=$(TRYTOND_CONFIG) +env=TRYTOND_DATABASE_URI=$(TRYTOND_DATABASE_URI) +env=PYTHONOPTIMIZE=$(PYTHONOPTIMIZE) +wsgi=trytond.application:app +processes=1 +threads=4 \ No newline at end of file