diff --git a/logging.conf b/logging.conf new file mode 100644 index 0000000..6803fab --- /dev/null +++ b/logging.conf @@ -0,0 +1,37 @@ +[formatters] +keys: simple, default + +[handlers] +keys: rotate, console, sentry + +[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/tryton/also60prod.log', 'D', 1, 30) +formatter: simple + +[logger_root] +level: INFO +handlers: rotate, console, sentry +propagate: False + +[formatter_default] +format=%(process)s %(thread)s [%(asctime)s] %(levelname)s %(name)s %(message)s + +[handler_console] +level=INFO +class=logging.StreamHandler +args=(sys.stdout,) +formatter=default + +[handler_sentry] +level=ERROR +class=sentry_tryton.SentryTrytonHandler +args=('https://28b6aa6a4ee7463faaab678f7e558d00@glitch.aklaro.si/2?verify_ssl=0', 'An error have been occurred.\nOur suport team have been reported.', 'Use "{event_id}" to reference this error.',) + diff --git a/nginx/tryton b/nginx/tryton new file mode 100644 index 0000000..48f9b47 --- /dev/null +++ b/nginx/tryton @@ -0,0 +1,31 @@ +server { + listen 8000; + server_name _; + + root /home/tryton/atl60prod/sao/; + index index.html; + + charset utf-8; + + client_max_body_size 2G; + + # ssl on; + # ssl_certificate /home/tryton/also56/ssl/fullchain.pem + # ssl_certificate_key /home/tryton/also56/ssl/privkey.pem + + location / { + proxy_set_header Origin ''; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + + keepalive_timeout 900s; + proxy_read_timeout 1800s; + proxy_send_timeout 1200s; + send_timeout 1200s; + proxy_ignore_client_abort on; + + proxy_pass http://127.0.0.1:5160; + } +} \ No newline at end of file diff --git a/scripts/run-trytond-admin.sh b/scripts/run-trytond-admin.sh new file mode 100644 index 0000000..0c7b51a --- /dev/null +++ b/scripts/run-trytond-admin.sh @@ -0,0 +1,2 @@ +#!/bin/bash +trytond-admin -c trytond.conf --logconf logging.conf -d also -v -u $1 diff --git a/scripts/run-trytond-cron.sh b/scripts/run-trytond-cron.sh new file mode 100644 index 0000000..c604980 --- /dev/null +++ b/scripts/run-trytond-cron.sh @@ -0,0 +1,2 @@ +#!/bin/bash +trytond-cron -c trytond.conf --logconf logging.conf -d also diff --git a/scripts/run-trytond-install.sh b/scripts/run-trytond-install.sh new file mode 100644 index 0000000..437aaac --- /dev/null +++ b/scripts/run-trytond-install.sh @@ -0,0 +1,2 @@ +#!/bin/bash +pip install --upgrade "$1 <5.3=>5.2" \ No newline at end of file diff --git a/scripts/run-trytond-upgrade.sh b/scripts/run-trytond-upgrade.sh new file mode 100644 index 0000000..431e503 --- /dev/null +++ b/scripts/run-trytond-upgrade.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +list_packages() { + pip freeze | grep '^trytond' | sed 's/==.*//' +} + +upgrade_package() { + local package_name=$1 + local version=$2 + pip install --upgrade "${package_name}<${version}" +} + +packages=$(list_packages) + +for package in $packages; do + echo "Upgrading package: $package" + upgrade_package "$package" "$1" +done diff --git a/scripts/run-trytond-worker.sh b/scripts/run-trytond-worker.sh new file mode 100644 index 0000000..6ad7788 --- /dev/null +++ b/scripts/run-trytond-worker.sh @@ -0,0 +1,2 @@ +#!/bin/bash +trytond-worker -c trytond.conf --logconf logging.conf -d also -n 1 diff --git a/scripts/run-trytond.sh b/scripts/run-trytond.sh new file mode 100644 index 0000000..81baa81 --- /dev/null +++ b/scripts/run-trytond.sh @@ -0,0 +1,2 @@ +#!/bin/bash +trytond -c trytond.conf -v --logconf logging.conf \ No newline at end of file diff --git a/system/trytond-also60prod.cron.service b/system/trytond-also60prod.cron.service new file mode 100644 index 0000000..4a85ebe --- /dev/null +++ b/system/trytond-also60prod.cron.service @@ -0,0 +1,16 @@ +[Unit] +Description = Cron Trytond +After = syslog.target + +[Service] +ExecStart = /opt/kitchen/venv/bin/trytond-cron -c /opt/kitchen/trytond.conf --logconf /opt/kitchen/logging.conf -d kitchen +Restart = always +KillSignal = SIGQUIT +Type = simple +StandardError = syslog +NotifyAccess = all +User=blaz +Group=blaz + +[Install] +WantedBy = multi-user.target diff --git a/system/trytond-also60prod.uwsgi.service b/system/trytond-also60prod.uwsgi.service new file mode 100644 index 0000000..5e9da2b --- /dev/null +++ b/system/trytond-also60prod.uwsgi.service @@ -0,0 +1,16 @@ +[Unit] +Description = uWSGI Trytond +After = syslog.target + +[Service] +ExecStart = /usr/bin/uwsgi --ini /opt/kitchen/uwsgi.ini +Restart = always +KillSignal = SIGQUIT +Type = notify +StandardError = syslog +NotifyAccess = all +User=blaz +Group=blaz + +[Install] +WantedBy = multi-user.target diff --git a/system/trytond.also60prod.worker.service b/system/trytond.also60prod.worker.service new file mode 100644 index 0000000..20ac744 --- /dev/null +++ b/system/trytond.also60prod.worker.service @@ -0,0 +1,16 @@ +[Unit] +Description = Worker Trytond +After = syslog.target + +[Service] +ExecStart = /opt/kitchen/venv/bin/trytond-worker -c /opt/kitchen/trytond.conf --logconf /opt/kitchen/logging.conf -d kitchen +Restart = always +KillSignal = SIGQUIT +Type = simple +StandardError = syslog +NotifyAccess = all +User=blaz +Group=blaz + +[Install] +WantedBy = multi-user.target diff --git a/trytond.conf b/trytond.conf new file mode 100644 index 0000000..4254a02 --- /dev/null +++ b/trytond.conf @@ -0,0 +1,19 @@ +[web] +listen = 0.0.0.0:8003 +root = /home/tryton/atl60prod/sao +#email_validation_url = http://minerva.dissidens.si:4000/validate/ +#reset_password_url = http://minerva.dissidens.si:4000/passwordreset/ + +[email] +uri = smtp://de-smtp.root.local +#uri = smtp://10.75.9.56 +from = tryton.si@also.com + +[database] +uri = postgresql://tryton:tryton@localhost +path = var/lib/trytond +language = en +#list = False + +[queue] +worker = True diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 0000000..91ae76e --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,12 @@ +[uwsgi] +http-socket = 0.0.0.0:5160 +master = true +chdir = /home/tryton/also60prod +virtualenv = /home/tryton/also60prod/.venv +wsgi = trytond.application:app +processes = 4 +threads = 2 +env = TRYTOND_CONFIG=/home/tryton/also60prod/trytond.conf +env = TRYTOND_LOGGING_CONFIG=/home/tryton/also60prod/logging.conf +# env = TRYTOND_COROUTINE=True +env = TRYTOND_DATABASE_NAMES=also