Conversation
cherrypy/wsgiserver/__init__.py
Outdated
| # Select the appropriate socket | ||
| if isinstance(self.bind_addr, six.string_types): | ||
| self.socket = None | ||
| if os.environ.get('LISTEN_PID', None): |
There was a problem hiding this comment.
Why set default value to None? It's not necessary.
Moreover, os.getenv('LISTEN_PID') would be more verbose.
|
@webknjaz thanks for the review, i fixed your comments and pushed ! |
|
I tried restarting the builds, but the result is the same. Why would the tests not run on Travis with this patch? |
|
@jaraco I think, there's some issue with TravisCI itself. Look at the |
|
@jaraco I've found the same issue, which happened in the past: https://travis-ci.org/cherrypy/cherrypy/jobs/139925725 |
|
Okay.. I've tried running |
$ .tox/py27/bin/nosetests -s -v
nose.config: INFO: Set working dir to ~/src/cherrypy-xaiki/cherrypy
nose.config: INFO: Working directory ~/src/cherrypy-xaiki/cherrypy is a package; adding to sys.path
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.selector: INFO: ~/src/cherrypy-xaiki/cherrypy/cherryd is executable; skipped
nose.selector: INFO: ~/src/cherrypy-xaiki/cherrypy/daemon.py is executable; skipped
nose.selector: INFO: ~/src/cherrypy-xaiki/cherrypy/test/sessiondemo.py is executable; skipped
nose.selector: INFO: ~/src/cherrypy-xaiki/cherrypy/test/test_session.py is executable; skipped
$ echo $?
70 |
|
It looks there's something malformed in this patch. Even if I generate diff and apply it to working master it breaks nose command. |
This tiny patch implements systemd's socket activation mechanism[0] for cherrypy servers, it's based on work sponsored by Endless Computers[1] to package kalite[2] as a flatpak[3]. Socket Activation allows to setup a system so that systemd will sit on a port and start services 'on demand' (a little bit like inetd and xinetd used to do). This patch makes that mechanism work for any cherrypy service without modification. [0] http://0pointer.de/blog/projects/socket-activation.html [1] https://endlessm.com [2] https://learningequality.org/ka-lite/ [3] https://flatpak.org https://phabricator.endlessm.com/T4489 Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
|
@webknjaz it was the removal of |
|
@xaiki okay, seems good Could you plz include some documentation/examples of running cherrypy app with use of this feature? Also it would be nice to have some tests covering it. |
|
a test is a bit hard as you need to have systemd setup, we (endlessm.com) use that patch to enable kalite systemd activation, here's our system part: basically, you need to setup these files: to make it work |
|
@xaiki Could you plz describe this in docs/deploy.rst? |
Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
|
docs added to deploy.rst |
Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
|
added to the bind_addr docstring as it seemed more relevant. |
|
LGTM @jaraco I thinks this PR is ready for merge |
Otherwise this will always end up killing the server in the socket-activated scenario, as the port won't ever be occupied by cherrypy, since the socket is handled by systemd. Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
|
Excellent. Thanks everyone for putting this together. |
|
Pending release in 7.1.0. |
This tiny patch implements systemd's socket activation mechanism[0] for
cherrypy servers, it's based on work sponsored by Endless Computers[1] to
package kalite[2] as a flatpak[3].
Socket Activation allows to setup a system so that systemd will sit on a
port and start services 'on demand' (a little bit like inetd and xinetd
used to do). This patch makes that mechanism work for any cherrypy
service without modification.
[0] http://0pointer.de/blog/projects/socket-activation.html
[1] https://endlessm.com
[2] https://learningequality.org/ka-lite/
[3] https://flatpak.org
https://phabricator.endlessm.com/T4489
Signed-off-by: Niv Sardi xaiki@evilgiggle.com