-
Notifications
You must be signed in to change notification settings - Fork 38
use uwsgi instead of paste #471
base: develop
Are you sure you want to change the base?
Changes from 16 commits
b94c667
a03f4c3
d293ff2
8fda21d
60feb81
3b121e3
cd49610
9439517
439ca1c
038bf75
b712f26
4dc5398
e49fd89
eb4e135
398038b
0d75019
7582ed3
b72920a
3091da4
9b16c97
977b45e
85f6388
88d0937
92ad97a
fd03c1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ parts | |
| bin | ||
| local | ||
| /src/*_theme | ||
| /lib | ||
| lib64 | ||
| eggs | ||
| develop-eggs | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| ############################################################################## | ||
| # 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] | ||
| 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
its not working with sh. |
||
| source ${adhocpy:env-file} | ||
| ${buildout:parts-directory}/uwsgi/bin/uwsgi "$@" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we forking off uwsgi here? I'd rather not do that, since the original (bash) process doesn't serve any role.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do we fork here?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the line marked with this comment!? Every command you type in a shell gets forked off unless it's built-in, so bash keeps running while uwsgi is serving. If that's not intentional, we should prepend the line with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right! I wasn't aware of the forking. Replacing the shell process is indeed better. Thanks for the explanation. |
||
| mode = 755 | ||
|
|
||
| # configure | ||
| [uwsgi_conf] | ||
| conf = | ||
| #basics | ||
|
|
||
| http = ${adhocracy:host}:${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 | ||
|
|
||
| #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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,6 @@ | |
| ############################################################## | ||
|
|
||
| [DEFAULT] | ||
| {% if parts.adhocracy.debug == 'True' %}debug = True {% end %} | ||
| {% if parts.adhocracy.debug != 'True' %}debug = False {% end %} | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this related to uwsgi?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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']} | ||
|
|
@@ -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 ################### | ||
|
|
||
| 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 = 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 = | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,19 +13,34 @@ parts = | |
| ${buildout:links-parts} | ||
|
|
||
| python-buildout-root = ${buildout:directory}/buildout.python/src | ||
| pil-install-args = Pillow==2.0.0 | ||
| pil-install-args = Pillow==2.0 | ||
|
|
||
|
|
||
| [install-links] | ||
| recipe = plone.recipe.command | ||
| prefix = ${buildout:directory}/.. | ||
| command = | ||
| command = | ||
| #!/bin/sh | ||
| mkdir -p ${install-links:prefix}/bin/ | ||
|
|
||
| # remove exiting links | ||
| rm ${:prefix}/bin/python | ||
| for i in $(ls ${:prefix}/bin/*[23].*); do | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks really unstable. Why do we need to remove the files in the first place? And why can't we match |
||
| rm $i; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just like in Python, semi-colons are not required here or in the lines below |
||
| done | ||
| rm ${:prefix}/include; | ||
| rm ${:prefix}/lib; | ||
|
|
||
| #Symlink default python (2.7) | ||
| DEST=${install-links:prefix}/bin/python; | ||
| ln -vfs ${buildout:directory}/python-2.7/bin/python2.7 $DEST; | ||
| update-command = ${:command} | ||
| # Symlink include, lib directory, uwsgi needs this there | ||
| ln -s ${buildout:directory}/python-2.7/include ${:prefix}/include | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also pass in the |
||
| 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we using ls here? Can't we just remove that?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2013/7/1 Philipp Hagemeister notifications@github.com
somentimes I need virtualenv-2.7, pip-27, easyinstall-27 or python-2.7
Joscha Krutzki • IT Consulting Python Webdevelopment Hosting |
||
| DEST=${:prefix}/bin/`basename $i`; | ||
| ln -s $i $DEST; | ||
| done | ||
| ln -s ${:prefix}/bin/python2.7 ${:prefix}/bin/python | ||
|
|
||
|
|
||
| update-command = ${:command} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these two entries used anywhere? It seems like we're simply using
{main:port}(as we should)