From 836ca8d2f045d0e60d8f33c5dc7fcf72feed4581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=A9na=C3=ABl=20Muller?= Date: Tue, 15 May 2018 15:18:31 +0200 Subject: [PATCH 1/4] allow to launch tracim with uwsgi --- README.md | 31 ++++++++++++++++++++++++------- wsgi/webdav.py | 10 ++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 wsgi/webdav.py diff --git a/README.md b/README.md index 4cbdf62..d3e5173 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ on Debian Stretch (9) with sudo: sudo apt update sudo apt install git sudo apt install python3 python3-venv python3-dev python3-pip + sudo apt install uwsgi uwsgi-plugin-python ### Get the source ### @@ -73,23 +74,39 @@ Initialize the database using [tracimcli](doc/cli.md) tool tracimcli db init -### Run Tracim_backend ### +create wsgidav configuration file for webdav: -Run your project: + cp wsgidav.conf.sample wsgidav.conf - pserve development.ini +## Run Tracim_backend ## -### Configure and Run Webdav Server (Unstable) ### +### With Uwsgi ### -create wsgidav configuration file : +Run all services with uwsgi - cp wsgidav.conf.sample wsgidav.conf + # pyramid webserver + uwsgi -d /tmp/tracim_web.log --http-socket :6543 --ini-paste-logged development.ini -H env --pidfile /tmp/tracim_web.pid + # webdav wsgidav server + uwsgi -d /tmp/tracim_webdav.log --http-socket :3030 --wsgi-file wsgi//webdav.py development.ini -H env --pidfile /tmp/tracim_webdav.pid + +to stop them: + + # pyramid webserver + uwsgi --stop /tmp/tracim_web.pid + # webdav wsgidav server + uswgi --stop /tmp/tracim_webdav.pid + +### With Waitress (legacy way, usefull for debug) ### + +run tracim_backend web api: + + pserve developement.ini run wsgidav server: tracimcli webdav start -### Run Tests and others checks ### +## Run Tests and others checks ## Run your project's tests: diff --git a/wsgi/webdav.py b/wsgi/webdav.py new file mode 100644 index 0000000..ac273eb --- /dev/null +++ b/wsgi/webdav.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# Runner for uwsgi +from tracim.lib.webdav import WebdavAppFactory + +APP_CONFIG = "development.ini" + +app_factory = WebdavAppFactory( + tracim_config_file_path=APP_CONFIG, +) +application = app_factory.get_wsgi_app() From 50bda15ef0da79872a3a8fe472866cb1ae26b854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=A9na=C3=ABl=20Muller?= Date: Wed, 16 May 2018 10:35:46 +0200 Subject: [PATCH 2/4] better uwsgi runner for both web and webdav --- README.md | 6 ++++-- wsgi/web.py | 9 +++++++++ wsgi/webdav.py | 6 +++--- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 wsgi/web.py diff --git a/README.md b/README.md index d3e5173..db74c92 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,12 @@ create wsgidav configuration file for webdav: Run all services with uwsgi + # set tracim_conf_file path + set TRACIM_CONF_PATH="$(pwd)/development.ini" # pyramid webserver - uwsgi -d /tmp/tracim_web.log --http-socket :6543 --ini-paste-logged development.ini -H env --pidfile /tmp/tracim_web.pid + uwsgi -d /tmp/tracim_web.log --http-socket :6543 --wsgi-file wsgi/web.py -H env --pidfile /tmp/tracim_web.pid # webdav wsgidav server - uwsgi -d /tmp/tracim_webdav.log --http-socket :3030 --wsgi-file wsgi//webdav.py development.ini -H env --pidfile /tmp/tracim_webdav.pid + uwsgi -d /tmp/tracim_webdav.log --http-socket :3030 --wsgi-file wsgi/webdav.py -H env --pidfile /tmp/tracim_webdav.pid to stop them: diff --git a/wsgi/web.py b/wsgi/web.py new file mode 100644 index 0000000..34f45a6 --- /dev/null +++ b/wsgi/web.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# Runner for uwsgi +import os +import pyramid.paster + +config_uri = os.environ['TRACIM_CONF_PATH'] + +pyramid.paster.setup_logging(config_uri) +application = pyramid.paster.get_app(config_uri) diff --git a/wsgi/webdav.py b/wsgi/webdav.py index ac273eb..a41c951 100644 --- a/wsgi/webdav.py +++ b/wsgi/webdav.py @@ -1,10 +1,10 @@ # coding=utf-8 # Runner for uwsgi from tracim.lib.webdav import WebdavAppFactory +import os -APP_CONFIG = "development.ini" - +config_uri = os.environ['TRACIM_CONF_PATH'] app_factory = WebdavAppFactory( - tracim_config_file_path=APP_CONFIG, + tracim_config_file_path=config_uri, ) application = app_factory.get_wsgi_app() From 3fed567a7f4fdbc705a4f2f5b33252a76bbdab11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=A9na=C3=ABl=20Muller?= Date: Wed, 16 May 2018 12:39:29 +0200 Subject: [PATCH 3/4] better uwsgi doc, install uwsgi with pip --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db74c92..991fa7b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ on Debian Stretch (9) with sudo: sudo apt update sudo apt install git sudo apt install python3 python3-venv python3-dev python3-pip - sudo apt install uwsgi uwsgi-plugin-python ### Get the source ### @@ -84,8 +83,10 @@ create wsgidav configuration file for webdav: Run all services with uwsgi + # install uwsgi with pip ( unneeded if you already have uwsgi with python3 plugin enabled) + sudo pip3 install uwsgi # set tracim_conf_file path - set TRACIM_CONF_PATH="$(pwd)/development.ini" + export TRACIM_CONF_PATH="$(pwd)/development.ini" # pyramid webserver uwsgi -d /tmp/tracim_web.log --http-socket :6543 --wsgi-file wsgi/web.py -H env --pidfile /tmp/tracim_web.pid # webdav wsgidav server From 79df94f1eb0e66f0b5288dd2e9a5625cbc0a969b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=A9na=C3=ABl=20Muller?= Date: Wed, 16 May 2018 14:50:10 +0200 Subject: [PATCH 4/4] fix webdav conf file : setup it in wsgi launcher --- README.md | 3 ++- wsgi/webdav.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 991fa7b..d247b6b 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Run all services with uwsgi sudo pip3 install uwsgi # set tracim_conf_file path export TRACIM_CONF_PATH="$(pwd)/development.ini" + export TRACIM_WEBDAV_CONF_PATH="$(pwd)/wsgidav.conf" # pyramid webserver uwsgi -d /tmp/tracim_web.log --http-socket :6543 --wsgi-file wsgi/web.py -H env --pidfile /tmp/tracim_web.pid # webdav wsgidav server @@ -97,7 +98,7 @@ to stop them: # pyramid webserver uwsgi --stop /tmp/tracim_web.pid # webdav wsgidav server - uswgi --stop /tmp/tracim_webdav.pid + uwsgi --stop /tmp/tracim_webdav.pid ### With Waitress (legacy way, usefull for debug) ### diff --git a/wsgi/webdav.py b/wsgi/webdav.py index a41c951..5dd2d1b 100644 --- a/wsgi/webdav.py +++ b/wsgi/webdav.py @@ -4,7 +4,9 @@ import os config_uri = os.environ['TRACIM_CONF_PATH'] +webdav_config_uri = os.environ['TRACIM_WEBDAV_CONF_PATH'] app_factory = WebdavAppFactory( tracim_config_file_path=config_uri, + webdav_config_file_path=webdav_config_uri, ) application = app_factory.get_wsgi_app()