Pool pubsub connections for notifications (#1626)

* Add a `listen()` method to `CTFd.utils.events.EventManager` and `CTFd.utils.events.RedisEventManager`. 
  * This method should implement subscription for a CTFd worker to whatever underlying notification system there is. This should be implemented with gevent or a background thread.
  * The `subscribe()` method (which used to also implement the functionality of the new `listen()` function) now only handles passing notifications from CTFd to the browser. This should also be implemented with gevent or a background thread. 
* Pool PubSub connections to Redis behind gevent. This improves the notification system by not having a pubsub connection per browser but instead per CTFd worker. This should reduce the difficulty in deploying the Notification system.
* Closes #1622 
* Make gevent default in serve.py and add a `--disable-gevent` switch in serve.py
* Revert to recommending `serve.py` first in README. `flask run` works but we don't get a lot of control.
* Add `tenacity` library for retrying logic
* Add `pytest-sugar` for slightly prettier pytest output
This commit is contained in:
Kevin Chung
2020-09-01 12:37:03 -04:00
committed by GitHub
parent f628f26495
commit 2bc66c1ecb
7 changed files with 157 additions and 61 deletions

View File

@@ -44,7 +44,7 @@ CTFd is a Capture The Flag framework focusing on ease of use and customizability
1. Install dependencies: `pip install -r requirements.txt`
1. You can also use the `prepare.sh` script to install system dependencies using apt.
2. Modify [CTFd/config.ini](https://github.com/CTFd/CTFd/blob/master/CTFd/config.ini) to your liking.
3. Use `flask run` in a terminal to drop into debug mode.
3. Use `python serve.py` or `flask run` in a terminal to drop into debug mode.
You can use the auto-generated Docker images with the following command: