From b94c667d4e491ebbc6b7ff00b46bdcec0971e7f3 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 19 Jun 2013 14:28:43 +0200 Subject: [PATCH 01/23] run adhocarcy with uwsgi instead of paster --- INSTALLATION.rst | 13 ++++-- buildout.cfg | 1 + buildouts/adhocracy.cfg | 3 +- buildouts/uwsgi.cfg | 94 ++++++++++++++++++++++++++++++++++++++ etc/adhocracy.ini.in | 7 +-- etc/uwsgi_buildconf.ini.in | 50 ++++++++++++++++++++ 6 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 buildouts/uwsgi.cfg create mode 100644 etc/uwsgi_buildconf.ini.in diff --git a/INSTALLATION.rst b/INSTALLATION.rst index e44e2e888..e3d30e80f 100644 --- a/INSTALLATION.rst +++ b/INSTALLATION.rst @@ -70,13 +70,13 @@ Check out Adhocracy: $ git clone https://github.com/liqd/adhocracy $ cd adhocracy - + $ git submodule init $ git submodule update ## Setup an isolated python environment to run Adhocracy -To install Adhocracy you need python (2.6|2.7) with PIL (python imaging) but +To install Adhocracy you need python (2.6|2.7) with PIL (python imaging) but no other system-packages. Compile python and PIL with the included python buildout:: @@ -92,7 +92,7 @@ Run buildout: :: - $ bin/python bootstrap.py + $ bin/python bootstrap.py $ bin/buildout Start Adhocracy and dependent servers: @@ -109,6 +109,7 @@ have to setup the Adhocracy database manually: $ bin/paster setup-app etc/adhocracy.ini --name=content + Run Adhocracy ------------- @@ -143,6 +144,12 @@ Start the Adhocracy server in foreground mode: $ bin/supervisorctl stop adhocracy $ bin/paster serve etc/adhocracy.ini +To run adhocarcy with uwsgi instead of paster: + +:: + $ bin/uwsgi --ini-paste etc/adhocracy.ini + + Buildout configuration ---------------------- diff --git a/buildout.cfg b/buildout.cfg index 67178033a..a77755536 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -11,6 +11,7 @@ extends = buildouts/base.cfg buildouts/lxml.cfg buildouts/adhocracy.cfg + buildouts/uwsgi.cfg # buildouts/adhocracy_theming.cfg buildouts/stylesheets.cfg buildouts/memcache.cfg diff --git a/buildouts/adhocracy.cfg b/buildouts/adhocracy.cfg index 600c2b141..b7c61b5f1 100644 --- a/buildouts/adhocracy.cfg +++ b/buildouts/adhocracy.cfg @@ -152,11 +152,12 @@ command = # python with all required eggs [adhocpy] -recipe = zc.recipe.egg +recipe = minitage.recipe.scripts eggs = ${buildout:eggs} extra-paths = ./ interpreter = adhocpy scripts = adhocpy +env-file = ${buildout:bin-directory}/adhocpy-env ############################################################################## # Set up supervisor to run it all diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg new file mode 100644 index 000000000..82e1e9541 --- /dev/null +++ b/buildouts/uwsgi.cfg @@ -0,0 +1,94 @@ +############################################################################## +# Buildout to install uwsgi https://github.com/unbit/uwsgi +# +# requires: +# +# - bin/adhocracpy-env to set the PYTHONPATH variable +# +############################################################################## + +[buildout] + +parts += + uwsgi + uwsgi_bin + +adhocracy-supervisor = + 45 adhocracy (environment=${supervisor:environment} redirect_stderr=true stdout_logfile=var/log/adhocracy.log stderr_logfile=NONE) ${buildout:bin-directory}/uwsgi [--ini-paste ${buildout:directory}/etc/adhocracy.ini] + +############################################################################## +# System settings +############################################################################## + +[domains] +uwsgi = 127.0.0.1 + +[ports] +uwsgi = 5008 + +[urls] +uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.12.tar.gz + +############################### +# Install and configure uwsgi # +############################### + +# compile options +[uwsgi_build_conf] +recipe = collective.recipe.template +output = ${buildout:etc-directory}/uwsgi_buildconf.ini +input = ${buildout:etc-directory}/uwsgi_buildconf.ini.in +bin-name = ${buildout:bin-directory}/uwsgi +plugin-dir = ${buildout:var-directory}/uwsgi_plugins +main-plugin = python, gevent + +[uwsgi_build_env] +UWSGI_PROFILE = ${uwsgi_build_profile:output} +PYTHONHOME = ${buildout:directory} + +# compile egg +[uwsgi] +recipe = minitage.recipe.du +url = ${urls:uwsgi} +eggs = + ${buildout:eggs} + uwsgi +environment = uwsgi_build_env + +# uwsgi bin +[uwsgi_bin] +recipe = collective.recipe.template +output = ${buildout:bin-directory}/uwsgi +input = inline: + #!/bin/bash + source ${adhocpy:env-file} + ${buildout:parts-directory}/uwsgi/bin/uwsgi "$@" +mode = 755 + +# configure +[uwsgi_conf] +conf = + #basics + http = 127.0.0.1:5001 + pidfile = /home/joka/dev/adhocracy/adhocracy/var/uwsgi.pid + master = true + chdir = /home/joka/dev/adhocracy/adhocracy/src + + #tuning + processes = 4 + worker = 20 + post-buffering = 4096 + max-requests = 1000 + # Reload if ini changes + touch-reload = true + # Reload a worker if its address space usage is higher than the specified value (in megabytes). + reload-on-as = 128 + no-orphans = true + + #logging + log-date = true + log-slow = true + + #gracefull dead + harakiri = 60 + harakiri-verbose = true diff --git a/etc/adhocracy.ini.in b/etc/adhocracy.ini.in index bba9b4f73..66deae94f 100644 --- a/etc/adhocracy.ini.in +++ b/etc/adhocracy.ini.in @@ -7,8 +7,6 @@ ############################################################## [DEFAULT] -{% if parts.adhocracy.debug == 'True' %}debug = True {% end %} -{% if parts.adhocracy.debug != 'True' %}debug = False {% end %} # Uncomment and replace with the address which should receive any error reports email_to = ${parts.adhocracy['email.to']} @@ -24,7 +22,10 @@ port = ${parts.ports.main} {% if parts.adhocracy.debug != 'True' %}use_threadpool = True {% end %} threadpool_workers = 20 - +{% if "uwsgi_conf" in parts %} +[uwsgi] +${parts.uwsgi_conf.conf} +{% end %} {% if parts.adhocracy.themed == 'False' %} ###################not themed adhocracy ################### diff --git a/etc/uwsgi_buildconf.ini.in b/etc/uwsgi_buildconf.ini.in new file mode 100644 index 000000000..bdbc87e25 --- /dev/null +++ b/etc/uwsgi_buildconf.ini.in @@ -0,0 +1,50 @@ +; this is mainly copied from the uwsgi buildconf/default.ini +; trying to surface some of the build options to buildout +; properties. +[uwsgi] +bin_name = ${:bin-name} +plugin_dir = ${:plugin-dir} +main_plugin = ${:main-plugin} +xml = true +ini = true +yaml = true +json = auto +sqlite3 = auto +zeromq = auto +snmp = true +spooler = true +embedded = true +ssl = auto +udp = true +multicast = true +threading = true +minterpreters = true +async = true +ldap = auto +pcre = auto +routing = auto +alarm = auto +ipv6 = false +debug = false +unbit = false +xml_implementation = libxml2 +yaml_implementation = auto +malloc_implementation = libc +extras = +plugins = +append_version = +embedded_plugins = %(main_plugin)s, ping, cache, nagios, rrdtool, carbon, rpc, corerouter, fastrouter, http, ugreen, signal, syslog, rsyslog, logsocket, router_uwsgi, router_redirect, router_basicauth, zergpool, redislog, mongodblog, router_rewrite, router_http, logfile, router_cache, rawrouter +as_shared_library = false + +locking = auto +event = auto +timer = auto +filemonitor = auto + +blacklist = +whitelist = + +embed_files = + +embed_config = + From a03f4c33e479b3c3f3fb05262ee64faaf6734f4e Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 19 Jun 2013 14:31:27 +0200 Subject: [PATCH 02/23] updated changelog --- CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 5fa0cb01f..0992e2a15 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,9 @@ adhocracy Changelog 1.2beta2dev ----------- +- run adhocarcy with uwsgi instead of paster to improve performance, + for development keep with paster [joka] + - Readd bin/test to run tests (wrapper for py.test) [joka] - Update python from 2.7.4 to 2.7.5. Please rebuild python: From d293ff268035d8cd82034b046d0c6db3338263a7 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 19 Jun 2013 14:37:18 +0200 Subject: [PATCH 03/23] use virtualenv to create python executables, uwsgi needs this --- .gitignore | 1 + CHANGES.txt | 11 +++++++++++ python/buildout.cfg | 22 +++++++++++++++------- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 5e0bb14fb..f1c3830de 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ parts bin local /src/*_theme +/lib/ lib64 eggs develop-eggs diff --git a/CHANGES.txt b/CHANGES.txt index 0992e2a15..3130df451 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,9 +4,20 @@ adhocracy Changelog 1.2beta2dev ----------- +- use virtualenv to create the python executable, uwsgi needs this. + + Upgrade manual installation: + ____________________________ + + * cd python + * bin/buildout + * cd .. + * bin/buildout + - run adhocarcy with uwsgi instead of paster to improve performance, for development keep with paster [joka] + - Readd bin/test to run tests (wrapper for py.test) [joka] - Update python from 2.7.4 to 2.7.5. Please rebuild python: diff --git a/python/buildout.cfg b/python/buildout.cfg index 91ce47218..aee66a1c8 100644 --- a/python/buildout.cfg +++ b/python/buildout.cfg @@ -10,21 +10,29 @@ parts = ${buildout:readline-parts} ${buildout:libjpeg-parts} ${buildout:python27-parts} - ${buildout:links-parts} + install-virtual-env + python-2.7-PIL python-buildout-root = ${buildout:directory}/buildout.python/src -pil-install-args = Pillow==2.0.0 +pil-install-args = Pillow==2.0 -[install-links] +[python-2.7-PIL] +location = ${install-virtual-env:prefix} + +[install-virtual-env] recipe = plone.recipe.command prefix = ${buildout:directory}/.. command = #!/bin/sh - mkdir -p ${install-links:prefix}/bin/ + mkdir -p ${:prefix}/bin/ + + #remove exiting python bin + rm ${:prefix}/bin/python + rm ${:prefix}/bin/python2.7 - #Symlink default python (2.7) - DEST=${install-links:prefix}/bin/python; - ln -vfs ${buildout:directory}/python-2.7/bin/python2.7 $DEST; + # create virtualenv (2.7) + DEST=${:prefix} + ${buildout:bin-directory}/virtualenv-2.7 --system-site-packages $DEST update-command = ${:command} From 8fda21d839e53f788b331cfcd127349bca79d56c Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 19 Jun 2013 14:52:16 +0200 Subject: [PATCH 04/23] improved uwsgi conf --- buildouts/uwsgi.cfg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 82e1e9541..072ba2db2 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -14,7 +14,7 @@ parts += uwsgi_bin adhocracy-supervisor = - 45 adhocracy (environment=${supervisor:environment} redirect_stderr=true stdout_logfile=var/log/adhocracy.log stderr_logfile=NONE) ${buildout:bin-directory}/uwsgi [--ini-paste ${buildout:directory}/etc/adhocracy.ini] + 45 adhocracy (environment=${supervisor:environment} stopsignal=INT redirect_stderr=true stdout_logfile=var/log/adhocracy.log stderr_logfile=NONE) ${buildout:bin-directory}/uwsgi [--ini-paste ${buildout:directory}/etc/adhocracy.ini] ############################################################################## # System settings @@ -69,13 +69,14 @@ mode = 755 [uwsgi_conf] conf = #basics - http = 127.0.0.1:5001 - pidfile = /home/joka/dev/adhocracy/adhocracy/var/uwsgi.pid + http = ${domains:main}:${ports:main} + pidfile = ${buildout:directory}/var/uwsgi.pid master = true - chdir = /home/joka/dev/adhocracy/adhocracy/src + chdir = ${buildout:directory}/src + home = ${buildout:directory} #tuning - processes = 4 + processes = 1 worker = 20 post-buffering = 4096 max-requests = 1000 From 60feb814f3ab947609fb14c613f75b43bd8acdef Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 19 Jun 2013 17:42:22 +0200 Subject: [PATCH 05/23] set LD_LIBRARY_PAT right to make PIL work --- buildouts/adhocracy.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildouts/adhocracy.cfg b/buildouts/adhocracy.cfg index b7c61b5f1..8c789114e 100644 --- a/buildouts/adhocracy.cfg +++ b/buildouts/adhocracy.cfg @@ -164,7 +164,7 @@ env-file = ${buildout:bin-directory}/adhocpy-env ############################################################################## [supervisor] -environment = LD_LIBRARY_PATH="${buildout:directory}/python/python-2.7/lib/" +environment = LD_LIBRARY_PATH="${buildout:directory}/lib/" programs += ${buildout:adhocracy_worker-supervisor} ${buildout:adhocracy-supervisor} From 3b121e32fb3c3ba927784b5e6cbea2c926ad26b2 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 19 Jun 2013 18:01:19 +0200 Subject: [PATCH 06/23] improved uwsgi conf --- buildouts/uwsgi.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 072ba2db2..830b85a2a 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -85,6 +85,10 @@ conf = # Reload a worker if its address space usage is higher than the specified value (in megabytes). reload-on-as = 128 no-orphans = true + # stop uwsgi if the wsgi app is not available + need-app = true + # allow threads + enable-threads = true #logging log-date = true From cd496100ea504ae50cf7db357b95c0ce7e0e5028 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Thu, 20 Jun 2013 13:09:11 +0200 Subject: [PATCH 07/23] nicer uwsgi conf --- buildouts/uwsgi.cfg | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 830b85a2a..34913d9e3 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -69,31 +69,43 @@ mode = 755 [uwsgi_conf] conf = #basics + http = ${domains:main}:${ports:main} pidfile = ${buildout:directory}/var/uwsgi.pid master = true chdir = ${buildout:directory}/src home = ${buildout:directory} + + # extended + + # Reload if ini changes + touch-reload = true + # stop uwsgi if the wsgi app is not available + need-app = true + # allow threads + enable-threads = true + #Set close-on-exec on sockets (could be required for spawning processes in requests). + close-on-exec = true + #Automatically kill workers if master dies (can be dangerous for availability). + no-orphans = true + # Try to remove all of the generated files/sockets (UNIX sockets and pidfiles) upon exit. + vacuum = true - #tuning + #performance tuning + processes = 1 worker = 20 post-buffering = 4096 max-requests = 1000 - # Reload if ini changes - touch-reload = true # Reload a worker if its address space usage is higher than the specified value (in megabytes). reload-on-as = 128 - no-orphans = true - # stop uwsgi if the wsgi app is not available - need-app = true - # allow threads - enable-threads = true - + #logging + log-date = true log-slow = true #gracefull dead + harakiri = 60 harakiri-verbose = true From 9439517b9d34253f945ffe89ddc5c4e9acfa3c59 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Thu, 20 Jun 2013 14:31:18 +0200 Subject: [PATCH 08/23] added script to open an interactive python shell with "IPDB()". --- INSTALLATION.rst | 2 ++ buildouts/uwsgi.cfg | 12 ++++++++---- scripts/interact.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 scripts/interact.py diff --git a/INSTALLATION.rst b/INSTALLATION.rst index e3d30e80f..02e8ec47e 100644 --- a/INSTALLATION.rst +++ b/INSTALLATION.rst @@ -149,6 +149,8 @@ To run adhocarcy with uwsgi instead of paster: :: $ bin/uwsgi --ini-paste etc/adhocracy.ini +To run the ipdb python debuger with uwsgi use "IPDB()" instead of "ipdb.set_trace()". + Buildout configuration ---------------------- diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 34913d9e3..b6290ccc8 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -99,13 +99,17 @@ conf = max-requests = 1000 # Reload a worker if its address space usage is higher than the specified value (in megabytes). reload-on-as = 128 + #gracefull dead + harakiri = 60 + harakiri-verbose = true #logging log-date = true log-slow = true - #gracefull dead - - harakiri = 60 - harakiri-verbose = true + # debug + + # IPDB(); opens python shell + shared-import = /home/joka/dev/adhocracy/adhocracy/scripts/interact.py + # memory-report = true diff --git a/scripts/interact.py b/scripts/interact.py new file mode 100644 index 000000000..8653297bf --- /dev/null +++ b/scripts/interact.py @@ -0,0 +1,31 @@ +"""uwsgi development helpers: open interactive python shells""" +import os +import sys +import inspect +import code + + +class RestoredStandardInputContext(object): + + def __enter__(self): + self.backup_stdin = os.dup(sys.stdin.fileno()) + os.dup2(sys.stdout.fileno(), sys.stdin.fileno()) + + def __exit__(self, error_type, error, traceback): + os.dup2(self.backup_stdin, sys.stdin.fileno()) + + +def interact(locals=None, plain=False): + + with RestoredStandardInputContext(): + code.interact(local=locals or inspect.currentframe().f_back.f_locals) + + +def interact_ipdb(): + + with RestoredStandardInputContext(): + import ipdb + ipdb.set_trace() + +__builtins__['PDB'] = interact +__builtins__['IPDB'] = interact_ipdb From b712f269c1fb221ec943347758b279040197624a Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Mon, 24 Jun 2013 22:10:35 +0200 Subject: [PATCH 09/23] link lib and include directory instead of using virtualenv --- CHANGES.txt | 2 +- python/buildout.cfg | 45 ++++++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c7f5a6eef..9f20f42d0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,7 +4,7 @@ adhocracy Changelog 1.2beta2dev ----------- -- use virtualenv to create the python executable, uwsgi needs this. +- link python lib and inclue directories, uwsgi needs this. Upgrade manual installation: ____________________________ diff --git a/python/buildout.cfg b/python/buildout.cfg index aee66a1c8..ef4e77a25 100644 --- a/python/buildout.cfg +++ b/python/buildout.cfg @@ -10,30 +10,49 @@ parts = ${buildout:readline-parts} ${buildout:libjpeg-parts} ${buildout:python27-parts} - install-virtual-env - python-2.7-PIL + ${buildout:links-parts} python-buildout-root = ${buildout:directory}/buildout.python/src pil-install-args = Pillow==2.0 -[python-2.7-PIL] -location = ${install-virtual-env:prefix} -[install-virtual-env] +[install-links] recipe = plone.recipe.command prefix = ${buildout:directory}/.. -command = +command = #!/bin/sh - mkdir -p ${:prefix}/bin/ + mkdir -p ${install-links:prefix}/bin/ + + # remove exiting links + rm ${:prefix}/bin/python + for i in $(ls ${:prefix}/bin/*[23].*); do + rm $i; + done + rm ${:prefix}/include; + rm ${:prefix}/lib; + + # Symlink include, lib directory, uwsgi needs this there + ln -s ${buildout:directory}/python-2.7/include ${:prefix}/include + ln -s ${buildout:directory}/python-2.7/lib ${:prefix}/lib + + # Symlink python, easy_install + for i in $(ls ${buildout:directory}/python-[23].*/bin/*[23].*); do + DEST=${:prefix}/bin/`basename $i`; + ln -s $i $DEST; + done + ln -s ${:prefix}/bin/python2.7 ${:prefix}/bin/python - #remove exiting python bin - rm ${:prefix}/bin/python - rm ${:prefix}/bin/python2.7 - # create virtualenv (2.7) - DEST=${:prefix} - ${buildout:bin-directory}/virtualenv-2.7 --system-site-packages $DEST update-command = ${:command} +#command = +##remove exiting python bin +#rm ${:prefix}/bin/python +#rm ${:prefix}/bin/python2.7 +## create virtualenv (2.7) +#DEST=${:prefix} +#${buildout:bin-directory}/virtualenv-2.7 --system-site-packages $DEST +#update-command = ${:command} + From 4dc5398126af2d6eff7a272b7c442b6208384139 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Sun, 30 Jun 2013 18:21:29 +0200 Subject: [PATCH 10/23] cleanup --- python/buildout.cfg | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/python/buildout.cfg b/python/buildout.cfg index ef4e77a25..99bdff08e 100644 --- a/python/buildout.cfg +++ b/python/buildout.cfg @@ -44,15 +44,3 @@ command = update-command = ${:command} - -#command = -##remove exiting python bin -#rm ${:prefix}/bin/python -#rm ${:prefix}/bin/python2.7 -## create virtualenv (2.7) -#DEST=${:prefix} -#${buildout:bin-directory}/virtualenv-2.7 --system-site-packages $DEST -#update-command = ${:command} - - - From e49fd899e58df92fc543d0186776a3d2b29cbe10 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 1 Jul 2013 03:07:14 +0200 Subject: [PATCH 11/23] [build.sh] Rebuild Python if lib/ is missing --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 054037992..75924b5d1 100755 --- a/build.sh +++ b/build.sh @@ -274,7 +274,7 @@ if [ '!' -e python/buildout.python/src ]; then fi # Install local python if necessary -if [ '!' -x bin/python ]; then +if [ '!' -x bin/python ] || [ '!' -e lib ]; then if [ '!' -f python/bin/buildout ]; then (cd python && python bootstrap.py) fi From eb4e135bdd51d3091861333ba3ee6309054eb7fe Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 1 Jul 2013 03:11:17 +0200 Subject: [PATCH 12/23] Remove hardcoded path --- buildouts/uwsgi.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index b6290ccc8..13c921d18 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -111,5 +111,5 @@ conf = # debug # IPDB(); opens python shell - shared-import = /home/joka/dev/adhocracy/adhocracy/scripts/interact.py + shared-import = ${buildout:directory}/scripts/interact.py # memory-report = true From 398038bac496abfe851cb75c64c4cab986b3b1c2 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 1 Jul 2013 03:24:24 +0200 Subject: [PATCH 13/23] Fix gitignore: lib is a symlink, not a directory --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4fc108ced..d54f85968 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ parts bin local /src/*_theme -/lib/ +/lib lib64 eggs develop-eggs From 0d75019a6b8b345e4b6b4f0c894d5510e9677500 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 1 Jul 2013 03:33:05 +0200 Subject: [PATCH 14/23] Fix listen --- buildouts/uwsgi.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 13c921d18..9ffb0914d 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -70,7 +70,7 @@ mode = 755 conf = #basics - http = ${domains:main}:${ports:main} + http = ${adhocracy:host}:${ports:main} pidfile = ${buildout:directory}/var/uwsgi.pid master = true chdir = ${buildout:directory}/src From 7582ed3e617be299c164380215ba3ccfe4724d01 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Tue, 2 Jul 2013 16:59:58 +0200 Subject: [PATCH 15/23] Fix: uwsgi process is forking off --- buildouts/uwsgi.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 9ffb0914d..98fc15025 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -60,9 +60,9 @@ environment = uwsgi_build_env recipe = collective.recipe.template output = ${buildout:bin-directory}/uwsgi input = inline: - #!/bin/bash + #!/bin/sh source ${adhocpy:env-file} - ${buildout:parts-directory}/uwsgi/bin/uwsgi "$@" + exec ${buildout:parts-directory}/uwsgi/bin/uwsgi "$@" mode = 755 # configure From b72920a20b048015819dca7e9aec9594ab1ef1ad Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Tue, 2 Jul 2013 17:12:44 +0200 Subject: [PATCH 16/23] Cleanup linking the python binaries and lib directory --- python/buildout.cfg | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/python/buildout.cfg b/python/buildout.cfg index 99bdff08e..30de23b3f 100644 --- a/python/buildout.cfg +++ b/python/buildout.cfg @@ -23,24 +23,16 @@ command = #!/bin/sh mkdir -p ${install-links:prefix}/bin/ - # remove exiting links - rm ${:prefix}/bin/python - for i in $(ls ${:prefix}/bin/*[23].*); do - rm $i; - done - rm ${:prefix}/include; - rm ${:prefix}/lib; - # Symlink include, lib directory, uwsgi needs this there - ln -s ${buildout:directory}/python-2.7/include ${:prefix}/include - ln -s ${buildout:directory}/python-2.7/lib ${:prefix}/lib + ln -sfT ${buildout:directory}/python-2.7/include ${:prefix}/include + ln -sfT ${buildout:directory}/python-2.7/lib ${:prefix}/lib # Symlink python, easy_install for i in $(ls ${buildout:directory}/python-[23].*/bin/*[23].*); do - DEST=${:prefix}/bin/`basename $i`; - ln -s $i $DEST; + DEST=${:prefix}/bin/`basename $i` + ln -sf $i $DEST done - ln -s ${:prefix}/bin/python2.7 ${:prefix}/bin/python + ln -sf ${:prefix}/bin/python2.7 ${:prefix}/bin/python update-command = ${:command} From 3091da42bd8ac6edba828bb257203bacc8f5e7e1 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Tue, 2 Jul 2013 18:20:14 +0200 Subject: [PATCH 17/23] Fix: buildout vars "etc-directory" and "var-directory" do not exists --- buildouts/uwsgi.cfg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 98fc15025..8a23e0fe2 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -36,14 +36,14 @@ uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.12.tar.gz # compile options [uwsgi_build_conf] recipe = collective.recipe.template -output = ${buildout:etc-directory}/uwsgi_buildconf.ini -input = ${buildout:etc-directory}/uwsgi_buildconf.ini.in +output = ${buildout:directory}/etc/uwsgi_buildconf.ini +input = ${buildout:directory}/etc/uwsgi_buildconf.ini.in bin-name = ${buildout:bin-directory}/uwsgi -plugin-dir = ${buildout:var-directory}/uwsgi_plugins +plugin-dir = ${buildout:directory}/var/uwsgi_plugins main-plugin = python, gevent [uwsgi_build_env] -UWSGI_PROFILE = ${uwsgi_build_profile:output} +UWSGI_PROFILE = ${uwsgi_build_conf:output} PYTHONHOME = ${buildout:directory} # compile egg From 9b16c97f4784bfb37fd3ec4894fc5f1b3eebcb72 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Tue, 2 Jul 2013 18:23:59 +0200 Subject: [PATCH 18/23] Removed buildout options domains.main and ports.main Its better to use the domains/ports parts only for server hosts/ports settings and the adhocracy part for adhocracy configuration: * adhocracy.host is now domains.wsgi * port.main is now ports.wsgi * domains.main is no adhocracy.domain --- CHANGES.txt | 6 ++++++ buildouts/adhocracy.cfg | 7 +++---- buildouts/developtools.cfg | 9 ++++----- buildouts/uwsgi.cfg | 8 ++++---- etc/adhocracy.ini.in | 10 +++++----- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 9f20f42d0..02e8839e3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,12 @@ adhocracy Changelog 1.2beta2dev ----------- +- Buildout configuration parts changed: + + * adhocracy.host is now domains.wsgi + * port.main is now ports.wsgi + * domains.main is no adhocracy.domain + - link python lib and inclue directories, uwsgi needs this. Upgrade manual installation: diff --git a/buildouts/adhocracy.cfg b/buildouts/adhocracy.cfg index 8c789114e..8ab9aea78 100644 --- a/buildouts/adhocracy.cfg +++ b/buildouts/adhocracy.cfg @@ -41,10 +41,10 @@ parts += ############################################################################## [domains] -main = adhocracy.lan +wsgi = 127.0.0.1 [ports] -main = 5001 +wsgi = 5001 supervisor = 5010 ############################################################################## @@ -52,15 +52,14 @@ supervisor = 5010 ############################################################################## [adhocracy] +domain = adhocracy.lan #start adhocracy in debug mode debug = False #TODO use geo features (You also need to include postgres_with_postgis instead of postgres) geo = False # theme adhocracy with diazo and merge a wordpress blog. themed = False - protocol = http -host = 127.0.0.1 #Session secret, replace this with a randomly generated hash value or use "autogenerated" to let #buildout do the job secret = autogenerated diff --git a/buildouts/developtools.cfg b/buildouts/developtools.cfg index 1af7c8bad..b67a9af26 100644 --- a/buildouts/developtools.cfg +++ b/buildouts/developtools.cfg @@ -37,17 +37,16 @@ eggs += ZopeSkel [adhocracy] debug = True +# generate internal urls with port 5001 to be able to work without a +# proxy (e.g. apache with ReverseProxy, see /etc/vhost.ini.in) +# on a port != 80 +force_port = True smtp_port = 8825 relative_urls = True sqlalchemy.url = sqlite:///${buildout:directory}/var/development.db [ports] mailserver_port = ${adhocracy:smtp_port} -[domains] -# generate internal urls with port 5001 to be able to work without a -# proxy (e.g. apache with ReverseProxy, see /etc/vhost.ini.in) -# on a port != 80 -main.force_port = True [supervisor] programs -= diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 8a23e0fe2..bee7b6262 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -21,10 +21,10 @@ adhocracy-supervisor = ############################################################################## [domains] -uwsgi = 127.0.0.1 +wsgi = 127.0.0.1 [ports] -uwsgi = 5008 +wsgi = 5001 [urls] uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.12.tar.gz @@ -70,10 +70,10 @@ mode = 755 conf = #basics - http = ${adhocracy:host}:${ports:main} + http = ${domains:wsgi}:${ports:wsgi} pidfile = ${buildout:directory}/var/uwsgi.pid master = true - chdir = ${buildout:directory}/src + chdir = ${buildout:directory}/src home = ${buildout:directory} # extended diff --git a/etc/adhocracy.ini.in b/etc/adhocracy.ini.in index 5e5661a1c..07c0ad057 100644 --- a/etc/adhocracy.ini.in +++ b/etc/adhocracy.ini.in @@ -16,8 +16,8 @@ error_email_from = ${parts.adhocracy['email.from']} [server:main] use = egg:Paste#http -host = ${parts.adhocracy.host} -port = ${parts.ports.main} +host = ${parts.domains.wsgi} +port = ${parts.ports.wsgi} {% if parts.adhocracy.debug == 'True' %}use_threadpool = False {% end %} {% if parts.adhocracy.debug != 'True' %}use_threadpool = True {% end %} threadpool_workers = 20 @@ -167,9 +167,9 @@ adhocracy.interactive_debugging = true # active instance, e.g. "Test Instance" for test.adhocracy.lan. {% python -adhocracy_domain = parts['domains']['main'] -if parts['domains'].get('main.force_port', None): - adhocracy_domain += ':%s' % parts['ports']['main'] +adhocracy_domain = parts['adhocracy']['domain'] +if parts['domains'].get('adhocracy.force_port', None): + adhocracy_domain += ':%s' % parts['ports']['wsgi'] %} adhocracy.domain = ${adhocracy_domain} adhocracy.protocol = ${parts.adhocracy.protocol} From 977b45eaeec02863afa3d843ec25c873a6904eb5 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 3 Jul 2013 13:02:29 +0200 Subject: [PATCH 19/23] Fix: error message when starting uwsgi touch-reload = true is throws: "unable to stat() true, events will be triggered as soon as the file is created" --- buildouts/uwsgi.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index bee7b6262..f45dcec64 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -79,7 +79,7 @@ conf = # extended # Reload if ini changes - touch-reload = true + touch-reload = ${buildout:directory}/etc/adhocracy.ini # stop uwsgi if the wsgi app is not available need-app = true # allow threads From 85f638801ccc60670770aa8451d1ef8fffd78989 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 3 Jul 2013 13:03:13 +0200 Subject: [PATCH 20/23] Fix: uwsgi recompiles all the time --- buildouts/uwsgi.cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index f45dcec64..f41e31418 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -38,7 +38,7 @@ uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.12.tar.gz recipe = collective.recipe.template output = ${buildout:directory}/etc/uwsgi_buildconf.ini input = ${buildout:directory}/etc/uwsgi_buildconf.ini.in -bin-name = ${buildout:bin-directory}/uwsgi +bin-name = ${buildout:bin-directory}/uwsgi_original plugin-dir = ${buildout:directory}/var/uwsgi_plugins main-plugin = python, gevent @@ -48,7 +48,7 @@ PYTHONHOME = ${buildout:directory} # compile egg [uwsgi] -recipe = minitage.recipe.du +recipe = minitage.recipe.scripts url = ${urls:uwsgi} eggs = ${buildout:eggs} @@ -62,7 +62,8 @@ output = ${buildout:bin-directory}/uwsgi input = inline: #!/bin/sh source ${adhocpy:env-file} - exec ${buildout:parts-directory}/uwsgi/bin/uwsgi "$@" + PYTHONHOME = ${buildout:directory} + exec ${buildout:bin-directory}/uwsgi_original "$@" mode = 755 # configure From 88d0937cd13aa20a48723751278ba21577419024 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 3 Jul 2013 13:07:42 +0200 Subject: [PATCH 21/23] compile uwsgi without xml support to remove the libxml dependency --- etc/uwsgi_buildconf.ini.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/uwsgi_buildconf.ini.in b/etc/uwsgi_buildconf.ini.in index bdbc87e25..d47110f6e 100644 --- a/etc/uwsgi_buildconf.ini.in +++ b/etc/uwsgi_buildconf.ini.in @@ -5,7 +5,7 @@ bin_name = ${:bin-name} plugin_dir = ${:plugin-dir} main_plugin = ${:main-plugin} -xml = true +xml = false ini = true yaml = true json = auto From 92ad97ab3caef5fc4c46e1393c5aaeb68f5978c9 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 3 Jul 2013 13:42:24 +0200 Subject: [PATCH 22/23] updated uwsgi to 1.9.13 to enable support of --- buildouts/uwsgi.cfg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index f41e31418..5c1dd2438 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -27,7 +27,7 @@ wsgi = 127.0.0.1 wsgi = 5001 [urls] -uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.12.tar.gz +uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.13.tar.gz ############################### # Install and configure uwsgi # @@ -45,6 +45,7 @@ main-plugin = python, gevent [uwsgi_build_env] UWSGI_PROFILE = ${uwsgi_build_conf:output} PYTHONHOME = ${buildout:directory} +UWSGI_INCLUDES = ${buildout:directory}/lib # compile egg [uwsgi] @@ -52,7 +53,7 @@ recipe = minitage.recipe.scripts url = ${urls:uwsgi} eggs = ${buildout:eggs} - uwsgi + uwsgi environment = uwsgi_build_env # uwsgi bin @@ -62,7 +63,8 @@ output = ${buildout:bin-directory}/uwsgi input = inline: #!/bin/sh source ${adhocpy:env-file} - PYTHONHOME = ${buildout:directory} + LD_LIBRARY_PATH = ${uwsgi_build_env:UWSGI_INCLUDES} + export LD_LIBRARY_PATH exec ${buildout:bin-directory}/uwsgi_original "$@" mode = 755 From fd03c1c891f3f8e4dffcf08ebcb2292133ab07a7 Mon Sep 17 00:00:00 2001 From: Joscha Krutzki Date: Wed, 3 Jul 2013 15:33:04 +0200 Subject: [PATCH 23/23] Fix: uwsgi start script does not run mit 'bin/sh' --- buildouts/uwsgi.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildouts/uwsgi.cfg b/buildouts/uwsgi.cfg index 5c1dd2438..1c94103d5 100644 --- a/buildouts/uwsgi.cfg +++ b/buildouts/uwsgi.cfg @@ -61,7 +61,7 @@ environment = uwsgi_build_env recipe = collective.recipe.template output = ${buildout:bin-directory}/uwsgi input = inline: - #!/bin/sh + #!/bin/bash source ${adhocpy:env-file} LD_LIBRARY_PATH = ${uwsgi_build_env:UWSGI_INCLUDES} export LD_LIBRARY_PATH