circus-tent / chaussette Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://chaussette.readthedocs.org
License: Other
Home Page: https://chaussette.readthedocs.org
License: Other
In the list of supported backends, see https://github.com/mozilla-services/chaussette/blob/master/docs/source/index.rst
Hello,
I'm running applications such as django and flask using chaussette through circus with gevent as my backend.
Chaussette does not log any of the incoming requests, though.
Is there a way to configure chaussette to do this without changing its code?
Here is the backtrace:
2016-09-13 14:35:42 [30] [INFO] Application is <bottle.Bottle object at 0x119d550>
2016-09-13 14:35:42 [30] [INFO] Serving on fd://9
2016-09-13 14:35:42 [30] [INFO] Using <class 'chaussette.backend._waitress.Server'> as a backend
Traceback (most recent call last):
File "/usr/local/bin/chaussette", line 9, in <module>
load_entry_point('chaussette==1.3.0', 'console_scripts', 'chaussette')()
File "/usr/local/lib/python2.7/dist-packages/chaussette/server.py", line 224, in main
inner()
File "/usr/local/lib/python2.7/dist-packages/chaussette/server.py", line 205, in inner
socket_type=_SOCKET_TYPE[args.socket_type])
File "/usr/local/lib/python2.7/dist-packages/chaussette/server.py", line 38, in make_server
server = server_class((host, port), app, **server_class_kwargs)
File "/usr/local/lib/python2.7/dist-packages/chaussette/backend/_waitress.py", line 20, in __init__
port=port)
File "/usr/local/lib/python2.7/dist-packages/waitress/server.py", line 148, in __init__
adj = Adjustments(**kw)
File "/usr/local/lib/python2.7/dist-packages/waitress/adjustments.py", line 278, in __init__
raise ValueError('Invalid host/port specified.')
ValueError: Invalid host/port specified.
Note that the same application is working well with waitress v0.9.0.
After some initial quick testing, I seem to be able to run my Pyramid based Python 3.3 application using a 2to3
converted Chaussette and Circus running on Python 2.7.
While I am looking forward to Python 3.3 support on Circus so I can run a Python 3 only stack, this is a reasonable interim solution.
Since Chaussette seems to just work with an automatic 2to3
conversion, I am convinced that creating a patch to add support to the existing code base for Python 3.3 will be trivial (correctly me if I am wrong but only Python >= 2.6 is officially supported, right?).
My question is: if I submit a pull request with the changes to support Python 3.3, would the project consider to start officially supporting Python 3.3 also?
With latest version of gevent-socketio, the backend seems broken. A chaussette server with the demo app is not working, requests don't get any answers and, if chaussette is killed, an error about missing attribute config is thrown.
virtualenv circtest
cd circtest
. bin/activate
pip install "psutils<2.0"
pip install circus chaussette gevent-socketio
chaussette --port 8080 --host 0.0.0.0 --backend socketio --log-level debug --log-output /tmp/chausette.log &
get localhost:8080
--2014-03-17 09:02:41-- http://localhost:8080/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response...^C
(done since nothing append)
fg
^C
Traceback (most recent call last):
File "/home/vagrant/circtest/local/lib/python2.7/site-packages/gevent/baseserver.py", line 140, in _do_read
args = self.do_read()
File "/home/vagrant/circtest/local/lib/python2.7/site-packages/gevent/server.py", line 93, in do_read
client_socket, address = self.socket.accept()
KeyboardInterrupt
<Server at 0x229c610 fileno=4 address=0.0.0.0:8080> failed with KeyboardInterrupt
Traceback (most recent call last):
File "/home/vagrant/circtest/local/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run
result = self._run(*self.args, **self.kwargs)
File "/home/vagrant/circtest/local/lib/python2.7/site-packages/socketio/server.py", line 123, in handle
handler = self.handler_class(self.config, socket, address, self)
AttributeError: 'Server' object has no attribute 'config'
<Greenlet at 0x25412d0: <bound method Server.handle of <Server at 0x229c610 fileno=4 address=0.0.0.0:8080>>(<socket at 0x254c110 fileno=7 sock=127.0.0.1:8080 , ('127.0.0.1', 55358))> failed with AttributeError
Bjoern supports Python 3 since version 2.0.0. So I think it should be enabled.
One caveat: During my testing I could only get Bjoern to work flawlessly with so_reuseport
set to True in my circusd config. Without this option I would get a hang every 200 requests or so. Why I'm not sure.
http://pypi.python.org/packages/source/c/chaussette/chaussette-0.4.tar.gz
under chaussette-0.4/ there is a nice bit of Django code called reseaugrappe.
Calling chaussette
with the --python-path
option to load a module in a subdirectory fails. The argument is defined in https://github.com/circus-tent/chaussette/blob/master/chaussette/server.py#L142 but args.python_path
is never referenced.
chaussette.util.resolve_name(name) can be replaced with this code, which seems to work better
http://werkzeug.pocoo.org/docs/utils/#werkzeug.utils.import_string
I mention this only because it says "# FIXME clean up this code!"
When using ChaussetteServer as backend, I can not kill chaussette with a Ctrl+C. Output:
Application is <flask.app.Flask object at 0x101daf410>
Serving on localhost:8080
Using <class chaussette.backend._wsgiref.ChaussetteServer at 0x1005c4d50> as a backend
FD - - [23/Sep/2012 15:39:43] "GET / HTTP/1.1" 404 238
FD - - [23/Sep/2012 15:39:43] "GET /favicon.ico HTTP/1.1" 404 238
FD - - [23/Sep/2012 15:39:43] "GET / HTTP/1.1" 404 238
FD - - [23/Sep/2012 15:39:43] "GET /favicon.ico HTTP/1.1" 404 238
FD - - [23/Sep/2012 15:39:43] "GET / HTTP/1.1" 404 238
FD - - [23/Sep/2012 15:39:44] "GET /favicon.ico HTTP/1.1" 404 238
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
If I use fastgevent or gevent I can kill chaussette with a Ctrl+C.
It would be nice to be able to kill chaussette whatever the backend used.
Environment:
chaussette==0.4
Python 2.7.3
Doesn't log anything when I do the following:
chaussette --log-level DEBUG --log-output chaussette.log --backend gevent wsgi.application
chaussette.log
is always empty and the log still shows on stdout.
Any ideas?
Hi Chaussette team,
How do i pass custom configuration parameters to my gevent backend? For instance this one: http://docs.gunicorn.org/en/latest/configure.html#limit-request-line. We need this setting for some operations in our production environment and i'm really hoping i dont have to abandon ship for gunicorn!
You guys rock. Thanks for this awesome product.
Jesse
Hello,
I'm using chaussette v1.3.0 (with circus) to host a pyramid web service that accepts large posts (32MB) and writes the body to a file. I'm using the --fd option.
After several requests, disk usage grows (until the volume is full) in proportion to the data POST'ed and lsof has many entries like the following for the chaussette process(es):
chaussett 26u REG 253,0 46789038 35843 /tmp/tmp2563Z5 (deleted)
chaussett 27u REG 253,0 46724414 49294 /tmp/tmpunH04b (deleted)
chaussett 28u REG 253,0 4096 34605 /tmp/ffiv6K58f (deleted)
chaussett 29u REG 253,0 46720826 35846 /tmp/tmpJzDbF4 (deleted)
chaussett 30u REG 253,0 46749554 50229 /tmp/tmpwEM6dV (deleted)
chaussett 31u REG 253,0 46760578 50230 /tmp/tmpoetYVY (deleted)
chaussett 32u REG 253,0 46737552 50236 /tmp/tmpLw0pQW (deleted)
chaussett 33u REG 253,0 46743846 55518 /tmp/tmpEQQDMM (deleted)
chaussett 34u REG 253,0 46759294 50237 /tmp/tmpJtagy5 (deleted)
chaussett 35u REG 253,0 46792302 63710 /tmp/tmpz_Fw9m (deleted)
chaussett 36u REG 253,0 46765054 63715 /tmp/tmpEgMn82 (deleted)
chaussett 37u REG 253,0 46787903 63720 /tmp/tmp2ylD4e (deleted)
chaussett 38u REG 253,0 46792459 63717 /tmp/tmpHBGzsZ (deleted)
chaussett 39u REG 253,0 46794015 63726 /tmp/tmpXK8Ngv (deleted)
chaussett 40u REG 253,0 46787845 63730 /tmp/tmpkoyBVZ (deleted)
chaussett 41u REG 253,0 46741383 63732 /tmp/tmp476UoG (deleted)
chaussett 42u REG 253,0 46802099 63733 /tmp/tmp0ukD2Q (deleted)
chaussett 43u REG 253,0 46817047 63738 /tmp/tmpibzajV (deleted)
chaussett 44u REG 253,0 46797917 63739 /tmp/tmpy9Xi0f (deleted)
Perhaps chaussette or circus deletes the tmp file without closing it?
When I restart my chaussette processes, disk usage goes back to normal. The waitress and gevent backends both had this behaviour, but not when I run the app directly with pserve.
Cheers.
bin/chaussette --fd $(circus.sockets.django) --backend fastgevent djangoproject.wsgi.application
File "lib/python2.7/site-packages/chaussette/backend/_fastgevent.py", line 25, in __init__
log, handler_class, environ, **ssl_args)
TypeError: __init__() got an unexpected keyword argument 'socket_type'
before more hacking on the project
See paste: http://hastebin.com/sigadoqupa.rb
I've tested this with Chaussette 0.7 0.8 and 0.9, exact same output. Waitress is 0.8.4 and essentially because get_backends only catches ImportErrors, Chaussette won't start even if you're not using waitress. When used with circus, it restarts chaussette indefinitely consuming a lot of CPU.
It would be great to integrate with bjoern. In my tests it was by far the fastest server around.
Trying to run a Django 1.6 app using Chaussette with gevent Backend occasionally raises thread exceptions (a Django exception actually!). This happens when Django tries to close old db connections.
Error:
...
DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 44709200 and this is thread id 67948624.
: Failed to handle request:
request = POST /api/sessions/ HTTP/1.0 from ['0.0.0.0']
application = django.core.handlers.wsgi.WSGIHandler object at 0x22f1750
Full stack trace here: http://pastebin.com/RpuyYrkW
I posted the error here, because when I remove the gevent backend, everything works fine, so I think involving gevent as a backend caused problems with Django 1.6
Running with gevent backend with a Django 1.4 worked fine.
I am still investigating the issue, and I will post my findings if any.
Regards,
2013-02-05 19:41:11 [28874] [INFO] Application is <pyramid.router.Router object at 0x9a250cc>
2013-02-05 19:41:11 [28874] [INFO] Serving on 127.0.0.1:8088
2013-02-05 19:41:11 [28874] [INFO] Using <class 'chaussette.backend._eventlet.Server'> as a backend
Traceback (most recent call last):
File "env/bin/chaussette", line 9, in
load_entry_point('chaussette==0.7', 'console_scripts', 'chaussette')()
File "/home/atomd/Workspace/Pearl/env/local/lib/python2.7/site-packages/chaussette/server.py", line 116, in main
socket_type=_SOCKET_TYPE[args.socket_type])
File "/home/atomd/Workspace/Pearl/env/local/lib/python2.7/site-packages/chaussette/server.py", line 25, in make_server
socket_type=socket_type)
TypeError: init() got an unexpected keyword argument 'socket_type'
Follow up of circus-tent/circus#986 when launching chaussette from the command line as follows :
/home/arthur/.virtualenvs/app/bin/chaussette --backend waitress --log-level debug --log-output - --use-reloader wsgi.app
I cannot CTRL-C it of kill SIGTERM or even kill -9 (even as root).
Versions :
chaussette (1.3.0)
circus (0.13.0)
Trying out the same options with the hello_app, works ok :
$ chaussette --backend waitress --log-level debug --log-output - --use-reloader
* Restarting with stat
2016-06-02 18:38:23 [12294] [INFO] Application is <function hello_app at 0x7fc53c386230>
2016-06-02 18:38:23 [12294] [INFO] Serving on localhost:8080
2016-06-02 18:38:23 [12294] [INFO] Using <class 'chaussette.backend._waitress.Server'> as a backend
^C
$
Any tips on what types of errors I could have in my wsgi app that would lead to such a problem ?
This might be a chaussette problem : circus-tent/circus#327
UpgradableWSGIHandler was removed from ws4py a few months ago and geventws4py backend cannot be initiated with the new ws4py version.
What is the course of action for this? Maintain backwards compatibility?
Hi,
I'm using chaussette with circus and meinheld. But I cannot get any stderr / stdout messages from the webapp even though these streams are redirected to the log files. I know that the webapp throws some exceptions but the log files are completely empty. If I run webapp manually without using chaussette I do get all messages in the console. Can it be that chaussette swallows the messages? Or perhaps meinheld? Or perhaps I'm missing something in the configuration? Or perhaps stderr / stdout are not correctly captured because of the virtualenv / copy_env ?
Below is my circus.ini file. Thanks
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557
httpd = True
httpd_host = 0.0.0.0
httpd_port = 8080
debug = True
[watcher:web]
working_dir = /home/k/projects/g/src/webapp
copy_env = True
virtualenv = /home/k/projects/g/ENV
cmd = chaussette --fd $(circus.sockets.web) --backend meinheld webapp.app
use_sockets = True
numprocesses = 1
warmup_delay = 5
# stdout_stream.class = StdoutStream
# stderr_stream.class = StdoutStream
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/webapp_err.log
stderr_stream.refresh_time = 0.3
# rotate the log file when it reaches 1 gb
# and save N copies of rotated files
stderr_stream.max_bytes = 1073741824
stderr_stream.backup_count = 2
stdout_stream.class = FileStream
stdout_stream.filename = /var/log/webapp_out.log
stdout_stream.refresh_time = 0.3
# rotate the log file when it reaches 1 gb
# and save N copies of rotated files
stdout_stream.max_bytes = 1073741824
stdout_stream.backup_count = 2
I have installed gevent 1.2.1 ,but when I start chaussette with backend gevent, a error occured "chaussette: error: argument --backend: invalid choice: 'gevent' (choose from 'tornado', 'wsgiref')"
the waitress backend crashes when there's a traceback
Chaussette has been great and we've had a great experience and excellent performance. When using the meinheld backend, though, the project will run smoothly for a time (even through benchmarks, etc) and almost randomly, but within a few hours nginx will fail to connect to the socket. The error message is:
connect() to unix:/tmp/chaussette.sock failed (11: Resource temporarily unavailable) while connecting to upstream
This doesn't happen with gevent (and we've switched to the gevent backend), but I wanted to report this in case it is effecting anyone else.
This could be a meinheld issue, so let me know, and I will report it there as well.
It crashes with
ValueError: Invalid host/port specified.
It appears it is fed with e.g. "fd://138080" for the port. Something must have changed api-wise for the passing of sockets descriptors.
Excuse my poor English.
I'm using pyramid and chaussette under circus. And my config file of circus is like this:
[watcher:pier]
working_dir = /home/web/Pier
cmd = env/bin/chaussette --fd $(circus.sockets.pier) paste:production.ini
uid = web
use_sockets = True
numprocesses = 5
stdout_stream.class = FileStream
stdout_stream.filename = /var/log/circus/pier.log
stdout_stream.refresh_time = 0.3
stdout_stream.max_bytes = 1073741824
stdout_stream.backup_count = 5
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/circus/pier.err
stderr_stream.refresh_time = 0.3
stderr_stream.max_bytes = 1073741824
stderr_stream.backup_count = 5
[socket:pier]
host = 127.0.0.1
port = 8080
But all logs are written to the file /var/log/circus/pier.err . And NO content in the file /var/log/circus/pier.err.
Have I made a silly config mistake ? Or I should config it through paste ?
I recently configured chaussette behind circus and when starting the service it used up 100% cpu. I found the reason was that when the backend or chaussette throws an error, it enters an infinite loop.
Additionally I found that any dashes in socket names throw an error (which thus cause an infinite loop)
I'm running chaussette 0.9, circus 0.9.2 on ubuntu
We want chaussette to die (to be restarted with circus) if the request take more than TIMEOUT seconds to be genrated.
This is a similar functionnality than the gunicorn timeout one.
It would be great to allow graceful shutdowns - where the server stops accepting new connections, but will allow a certain timeout for existing connections to complete, before terminating. Many of the backends already support such functionality, but this is not exposed by chaussette.
This would be particularly effective when used with a process manager that can restart services sequentially - allowing a complete "graceful restart" of chaussette without missing or dropping any connections.
I am experiencing conditional instabilities when running a python web-app that uses redis, when running it via choussette with the gevent back-end.
I ruled-out the factor of using 0.13.x versions of G-event vs. the 1.x release - it happens in both cases.
When I use any form of redis-integration, while using any other back-end, everything works smoothly.
When I use G-event of any version, while not using redis for anything, everything works smoothly.
But when combining the two, and using G-event of any version while using redis for anything (session-store and/or caching), things go haywire...
if I don't use chaussette then everything works smoothly with both g-event and redis.
I.e, this works with redis-integration in the app, but doesn't use gevent:
"cmd = /usr/bin/chaussette --fd $(circus.sockets.no_gevent) gluon.main.wsgibase"
This causes random crashed/hangs (when the app uses redis):
"cmd = /usr/bin/chaussette --fd $(circus.sockets.gevent) --backend gevent gluon.main.wsgibase"
This works with g-event and redis, but only when NOT using socket/chaussette:
"cmd = python anyserver.py -s gevent"
But then I can't run multiple python-processes...
All circus-advantages nullified...
( I.e: This sucks...)
I'm running Django 1.9.4 on top of Chausette + Nginx, supervised by Circus.
If non-existing ascii url is entered, like '/europeanunion', 404 error is returned, as expected.
But for non-ascii url like '/europäischenunion', code 400 is returned.
Url like 'европейскийсоюз' results in server 500 error with the following error:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 1-15: ordinal not in range(256)
Gunicorn server handles all such urls fine, returning expected 404
No release since 2015, no commit since 2017. Looks like a dead project.
Are people watching this place ? Is a complete takeover/fork necessary ?
[watcher:experiment]
cmd = chaussette experiment:app --fd $(circus.sockets.experiment) --backend waitress
use_sockets = True
copy_env = True
[socket:experiment]
host = 127.0.0.1
port = 5000
2014-12-27 16:20:03 circus[2270] [INFO] Starting master on pid 2270
2014-12-27 16:20:03 circus[2270] [INFO] sockets started
2014-12-27 16:20:03 circus[2270] [INFO] Arbiter now waiting for commands
2014-12-27 16:20:03 circus[2270] [INFO] experiment started
2014-12-27 16:20:03 [2274] [INFO] Application is <Flask 'experiment'>
2014-12-27 16:20:03 [2274] [INFO] Serving on fd://6
2014-12-27 16:20:03 [2274] [INFO] Using <class 'chaussette.backend._waitress.Server'> as a backend
Traceback (most recent call last):
File "/home/dmeunier/.env/chaussette/bin/chaussette", line 9, in
load_entry_point('chaussette==1.3', 'console_scripts', 'chaussette')()
File "/home/dmeunier/src/experiment/chaussette/chaussette/server.py", line 203, in main
inner()
File "/home/dmeunier/src/experiment/chaussette/chaussette/server.py", line 184, in inner
socket_type=_SOCKET_TYPE[args.socket_type])
File "/home/dmeunier/src/experiment/chaussette/chaussette/server.py", line 35, in make_server
server = server_class((host, port), app, **server_class_kwargs)
File "/home/dmeunier/src/experiment/chaussette/chaussette/backend/_waitress.py", line 20, in init
port=port)
File "/home/dmeunier/.env/chaussette/lib/python3.4/site-packages/waitress/server.py", line 77, in init
self.effective_host, self.effective_port = self.getsockname()
File "/home/dmeunier/.env/chaussette/lib/python3.4/site-packages/waitress/server.py", line 187, in getsockname
return self.socket.getsockname()
OSError: [Errno 88] Socket operation on non-socket
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.