Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

use uwsgi instead of paste #471

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b94c667
run adhocarcy with uwsgi instead of paster
joka Jun 19, 2013
a03f4c3
updated changelog
joka Jun 19, 2013
d293ff2
use virtualenv to create python executables, uwsgi needs this
joka Jun 19, 2013
8fda21d
improved uwsgi conf
joka Jun 19, 2013
60feb81
set LD_LIBRARY_PAT right to make PIL work
joka Jun 19, 2013
3b121e3
improved uwsgi conf
joka Jun 19, 2013
cd49610
nicer uwsgi conf
joka Jun 20, 2013
9439517
added script to open an interactive python shell with "IPDB()".
joka Jun 20, 2013
439ca1c
Merge branch 'develop' into feature_444_use_uwsgi_instead_of_paste
joka Jun 21, 2013
038bf75
Merge branch 'develop' into feature_444_use_uwsgi_instead_of_paste
joka Jun 21, 2013
b712f26
link lib and include directory instead of using virtualenv
joka Jun 24, 2013
4dc5398
cleanup
joka Jun 30, 2013
e49fd89
[build.sh] Rebuild Python if lib/ is missing
phihag Jul 1, 2013
eb4e135
Remove hardcoded path
phihag Jul 1, 2013
398038b
Fix gitignore: lib is a symlink, not a directory
phihag Jul 1, 2013
0d75019
Fix listen
phihag Jul 1, 2013
7582ed3
Fix: uwsgi process is forking off
joka Jul 2, 2013
b72920a
Cleanup linking the python binaries and lib directory
joka Jul 2, 2013
3091da4
Fix: buildout vars "etc-directory" and "var-directory" do not exists
joka Jul 2, 2013
9b16c97
Removed buildout options domains.main and ports.main
joka Jul 2, 2013
977b45e
Fix: error message when starting uwsgi
joka Jul 3, 2013
85f6388
Fix: uwsgi recompiles all the time
joka Jul 3, 2013
88d0937
compile uwsgi without xml support to remove the libxml dependency
joka Jul 3, 2013
92ad97a
updated uwsgi to 1.9.13 to enable support of
joka Jul 3, 2013
fd03c1c
Fix: uwsgi start script does not run mit 'bin/sh'
joka Jul 3, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ parts
bin
local
/src/*_theme
/lib
lib64
eggs
develop-eggs
Expand Down
19 changes: 19 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ 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:
____________________________

* cd python
* bin/buildout
* cd ..
* bin/buildout

- run adhocarcy with uwsgi instead of paster to improve performance,
for development keep with paster [joka]

- added varnish reverse proxy [joka]

- Readd bin/test to run tests (wrapper for py.test) [joka]
Expand Down
15 changes: 12 additions & 3 deletions INSTALLATION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -92,7 +92,7 @@ Run buildout:

::

$ bin/python bootstrap.py
$ bin/python bootstrap.py
$ bin/buildout

Start Adhocracy and dependent servers:
Expand All @@ -109,6 +109,7 @@ have to setup the Adhocracy database manually:

$ bin/paster setup-app etc/adhocracy.ini --name=content


Run Adhocracy
-------------

Expand Down Expand Up @@ -143,6 +144,14 @@ 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

To run the ipdb python debuger with uwsgi use "IPDB()" instead of "ipdb.set_trace()".


Buildout configuration
----------------------

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions buildouts/adhocracy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,25 @@ parts +=
##############################################################################

[domains]
main = adhocracy.lan
wsgi = 127.0.0.1

[ports]
main = 5001
wsgi = 5001
supervisor = 5010

##############################################################################
# Adhocracy settings
##############################################################################

[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
Expand Down Expand Up @@ -152,18 +151,19 @@ 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
##############################################################################

[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}
9 changes: 4 additions & 5 deletions buildouts/developtools.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 -=
Expand Down
118 changes: 118 additions & 0 deletions buildouts/uwsgi.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
##############################################################################
# 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} 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
##############################################################################

[domains]
wsgi = 127.0.0.1

[ports]
wsgi = 5001

[urls]
uwsgi = http://projects.unbit.it/downloads/uwsgi-1.9.13.tar.gz

###############################
# Install and configure uwsgi #
###############################

# compile options
[uwsgi_build_conf]
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_original
plugin-dir = ${buildout:directory}/var/uwsgi_plugins
main-plugin = python, gevent

[uwsgi_build_env]
UWSGI_PROFILE = ${uwsgi_build_conf:output}
PYTHONHOME = ${buildout:directory}
UWSGI_INCLUDES = ${buildout:directory}/lib

# compile egg
[uwsgi]
recipe = minitage.recipe.scripts
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be /bin/sh - the file is not dependent on bash at all, or is it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be /bin/sh - the file is not dependent on bash at all, or is it?

its not working with sh.

source ${adhocpy:env-file}
LD_LIBRARY_PATH = ${uwsgi_build_env:UWSGI_INCLUDES}
export LD_LIBRARY_PATH
exec ${buildout:bin-directory}/uwsgi_original "$@"
mode = 755

# configure
[uwsgi_conf]
conf =
#basics

http = ${domains:wsgi}:${ports:wsgi}
pidfile = ${buildout:directory}/var/uwsgi.pid
master = true
chdir = ${buildout:directory}/src
home = ${buildout:directory}

# extended

# Reload if ini changes
touch-reload = ${buildout:directory}/etc/adhocracy.ini
# 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

#performance tuning

processes = 1
worker = 20
post-buffering = 4096
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

# debug

# IPDB(); opens python shell
shared-import = ${buildout:directory}/scripts/interact.py
# memory-report = true
17 changes: 9 additions & 8 deletions etc/adhocracy.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
##############################################################

[DEFAULT]
{% if parts.adhocracy.debug == 'True' %}debug = True {% end %}
{% if parts.adhocracy.debug != 'True' %}debug = False {% end %}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to uwsgi?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This debug flag does not work with mutliprocess WSGI-servers such as uwsgi

# Uncomment and replace with the address which should receive any error reports
email_to = ${parts.adhocracy['email.to']}
Expand All @@ -18,13 +16,16 @@ 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


{% if "uwsgi_conf" in parts %}
[uwsgi]
${parts.uwsgi_conf.conf}
{% end %}

{% if parts.adhocracy.themed == 'False' %}
###################not themed adhocracy ###################
Expand Down Expand Up @@ -166,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}
Expand Down
50 changes: 50 additions & 0 deletions etc/uwsgi_buildconf.ini.in
Original file line number Diff line number Diff line change
@@ -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 = false
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 =

Loading