refactor: Deploy System
This commit is contained in:
401715
prod/common_password.txt
Normal file
401715
prod/common_password.txt
Normal file
File diff suppressed because one or more lines are too long
26
prod/gunicorn.conf.py
Normal file
26
prod/gunicorn.conf.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
|
||||
wsgi_app = 'trytond.application:app'
|
||||
bind = '0.0.0.0:8000'
|
||||
|
||||
# Number of worker processes
|
||||
workers = 2
|
||||
|
||||
# Worker class
|
||||
worker_class = "sync" # or "gevent" for I/O-bound tasks
|
||||
|
||||
# Timeout for requests
|
||||
timeout= 500
|
||||
|
||||
# Preload application
|
||||
preload_app = True
|
||||
|
||||
# Keep-alive
|
||||
keepalive = 5
|
||||
|
||||
raw_env = [
|
||||
'TRYTOND_CONFIG=%s' % os.environ.get('TRYTOND_CONFIG', ''),
|
||||
'TRYTOND_DATABASE_URI=%s' % os.environ.get('TRYTOND_DATABASE_URI', ''),
|
||||
'PYTHONOPTIMIZE=%s' % os.environ.get('PYTHONOPTIMIZE'),
|
||||
]
|
||||
|
||||
40
prod/install_modules.sh
Executable file
40
prod/install_modules.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
echo "Files in /app directory:"
|
||||
ls -la /app/
|
||||
|
||||
if [ -d "/app/modules" ] && [ "$(ls -A /app/modules)" ]; then
|
||||
module_names=()
|
||||
for module in /app/modules/*/; do
|
||||
echo "Processing module: $module"
|
||||
|
||||
pushd "$module" > /dev/null
|
||||
|
||||
# Install dependencies
|
||||
pip3 install . --break-system-packages
|
||||
|
||||
# Extract module name
|
||||
trytond_modules_path=$(pip3 show trytond | grep Location | sed -nr 's/Location: +//gp')/trytond/modules
|
||||
module_name=$(cat "setup.py" | grep -A 1 "\[trytond.modules\]" | sed 1d | cut -d '=' -f 1 | tr -d ' \n')
|
||||
|
||||
# Add to array
|
||||
module_names+=("$module_name")
|
||||
|
||||
# Validate path
|
||||
if [ ! -d "$trytond_modules_path" ]; then
|
||||
echo "ERROR: Failed to locate trytond modules path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create symlink (fix: use direct path, not $SRC)
|
||||
ln -sf "$module" "$trytond_modules_path/$module_name"
|
||||
|
||||
popd > /dev/null
|
||||
done
|
||||
|
||||
# Create colon-separated list
|
||||
module_names=$(IFS=:; echo "${module_names[*]}")
|
||||
echo "Installed modules: $module_names"
|
||||
fi
|
||||
21
prod/nginx.conf
Normal file
21
prod/nginx.conf
Normal file
@@ -0,0 +1,21 @@
|
||||
server {
|
||||
server_name ${SERVER_NAME};
|
||||
listen ${NGINX_PORT};
|
||||
client_max_body_size 50M;
|
||||
|
||||
sendfile on;
|
||||
send_timeout 500s;
|
||||
|
||||
location / {
|
||||
proxy_pass http://tryton:8000/; # "trytond" is the service name of another Docker container on port 8000
|
||||
proxy_read_timeout 500;
|
||||
proxy_connect_timeout 500;
|
||||
proxy_send_timeout 500;
|
||||
|
||||
proxy_set_header Host ${VARIABLE}host;
|
||||
proxy_set_header X-Real-IP ${VARIABLE}remote_addr;
|
||||
proxy_set_header X-Forwarded-For ${VARIABLE}proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host ${VARIABLE}server_name;
|
||||
proxy_set_header X-Forwarded-Proto ${VARIABLE}scheme;
|
||||
}
|
||||
}
|
||||
26
prod/start.sh
Normal file
26
prod/start.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
if [ -s /etc/trytond_populate.conf ]; then
|
||||
if [ "$DEVELOP" == "True" ]; then
|
||||
if [ "$WORKER" == "True" ]; then
|
||||
trytond -c /etc/trytond.conf --dev --logconf /etc/trytond_logging.conf
|
||||
# trytond-cron -c /etc/trytond.conf --dev --logconf /etc/trytond_cron_logging.conf &
|
||||
# trytond-worker -c /etc/trytond.conf -d miac --dev --logconf /etc/trytond_worker_logging.conf
|
||||
else
|
||||
trytond -c /etc/trytond.conf --dev --logconf /etc/trytond_logging.conf
|
||||
# trytond-cron -c /etc/trytond.conf --dev --logconf /etc/trytond_cron_logging.conf
|
||||
fi
|
||||
elif [ "$WORKER" == "True" ]; then
|
||||
# trytond-cron -c /etc/trytond.conf --dev --logconf /etc/trytond_cron_logging.conf &
|
||||
# trytond-worker -c /etc/trytond.conf -d miac --logconf /etc/trytond_worker_logging.conf &
|
||||
gunicorn --config=/etc/gunicorn.conf.py
|
||||
else
|
||||
gunicorn --config=/etc/gunicorn.conf.py
|
||||
fi
|
||||
else
|
||||
sleep $SLEEP_TRYTOND_ADMIN && echo $TRYTONADMINPASS > $TRYTONPASSFILE
|
||||
|
||||
trytond-admin -c /etc/trytond.conf -d $POSTGRES_DB --all --email $EMAIL -vv
|
||||
|
||||
echo "1" > /etc/trytond_populate.conf && /bin/bash /opt/start.sh
|
||||
fi
|
||||
16
prod/trytond.conf
Normal file
16
prod/trytond.conf
Normal file
@@ -0,0 +1,16 @@
|
||||
[web]
|
||||
listen=0.0.0.0:8000
|
||||
root=/var/lib/trytond/www
|
||||
cors=
|
||||
https://appdemo.naliia.co
|
||||
https://app.naliia.co
|
||||
http://localhost:5173
|
||||
|
||||
|
||||
[database]
|
||||
list=True
|
||||
path=/mnt/attachment
|
||||
lenguage=es
|
||||
|
||||
[password]
|
||||
forbidden=/etc/common_password.txt
|
||||
26
prod/trytond_cron_logging.conf
Normal file
26
prod/trytond_cron_logging.conf
Normal file
@@ -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
|
||||
26
prod/trytond_logging.conf
Normal file
26
prod/trytond_logging.conf
Normal file
@@ -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
|
||||
14
prod/trytond_worker.conf
Normal file
14
prod/trytond_worker.conf
Normal file
@@ -0,0 +1,14 @@
|
||||
[web]
|
||||
listen=0.0.0.0:8000
|
||||
root=/var/lib/trytond/www
|
||||
|
||||
[database]
|
||||
list=True
|
||||
path=/mnt/attachment
|
||||
lenguage=es
|
||||
|
||||
[password]
|
||||
forbidden=/etc/common_password.txt
|
||||
|
||||
[queue]
|
||||
worker = True
|
||||
26
prod/trytond_worker_logging.conf
Normal file
26
prod/trytond_worker_logging.conf
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user