mirror of
https://github.com/django/daphne.git
synced 2025-04-25 03:03:47 +03:00
* Added in simple locust file * Correcting the file name * Updated to latest version of daphne * moving settings up * Moved over channels settings * Removed channels settings * Removed settings file * Moved around files * Made a file for normal wsgi * Changed regular wsgi to point to channels settings * Create __init__.py * Added in the appropriate import * Named it right * Create urls_no_channels.py * Delete urls_no_channels.py * Doing this so I don't have to have multiple urls * Update urls.py * Update urls.py * Added in fabric cmd for installing nodejs loadtest * Added in git dependency * Added in a symlink for loadtest * Made run_loadtest command * Added in argument for time * Changed to format on string * Updated arguments * Fixed typo for argument * Made some comments and moved around some tasks * Edits to readme * Add a lot more documentation * Adjusted formatting * Added a comment * Made formatting cahnges * Slight language change * Changed name for testing * Changed name for testing * Update asgi.py * Added in alternate ChannelLayer * Rename chanells_inmemory.py to chanels_inmemory.py * Rename chanels_inmemory.py to channels_inmemory.py * Create asgi_inmemory * Rename asgi_inmemory to asgi_inmemory.py * Added in routing * Switching to instantiated class * Update channels_inmemory.py * Update channels_inmemory.py * Altered the fabric testing tasks * Update and rename asgi_inmemory.py to asgi_ipc.py * Update and rename channels_inmemory.py to channels_ipc.py * Updated to include asgi_ipc * Updated environment setup task * Spelling * Updated channel layer * Update asgi_ipc.py * Rename asgi_ipc.py to asgi_for_ipc.py * Update asgi_for_ipc.py * Trying something * Trying something else * Changed it back * changed back
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
from fabric.api import sudo, task, cd
|
|
|
|
# CHANNEL TASKS
|
|
@task
|
|
def setup_redis():
|
|
sudo("apt-get update && apt-get install -y redis-server")
|
|
sudo("sed -i -e 's/127.0.0.1/0.0.0.0/g' /etc/redis/redis.conf")
|
|
sudo("/etc/init.d/redis-server stop")
|
|
sudo("/etc/init.d/redis-server start")
|
|
|
|
|
|
@task
|
|
def setup_channels():
|
|
sudo("apt-get update && apt-get install -y git python-dev python-setuptools python-pip")
|
|
sudo("pip install -U pip")
|
|
sudo("pip install -U asgi_redis asgi_ipc git+https://github.com/andrewgodwin/daphne.git@#egg=daphne")
|
|
sudo("rm -rf /srv/channels")
|
|
sudo("git clone https://github.com/andrewgodwin/channels.git /srv/channels/")
|
|
with cd("/srv/channels/"):
|
|
sudo("python setup.py install")
|
|
|
|
|
|
@task
|
|
def run_daphne(redis_ip):
|
|
with cd("/srv/channels/testproject/"):
|
|
sudo("REDIS_URL=redis://%s:6379 daphne -b 0.0.0.0 -p 80 testproject.asgi:channel_layer" % redis_ip)
|
|
|
|
|
|
@task
|
|
def run_worker(redis_ip):
|
|
with cd("/srv/channels/testproject/"):
|
|
sudo("REDIS_URL=redis://%s:6379 python manage.py runworker" % redis_ip)
|
|
|
|
|
|
# Current loadtesting setup
|
|
@task
|
|
def setup_load_tester(src="https://github.com/andrewgodwin/channels.git"):
|
|
sudo("apt-get update && apt-get install -y git nodejs && apt-get install npm")
|
|
sudo("npm install -g loadtest")
|
|
sudo("ln -s /usr/bin/nodejs /usr/bin/node")
|
|
|
|
|
|
# Run current loadtesting setup
|
|
# example usage: $ fab run_loadtest:http://127.0.0.1,rps=10 -i "id_rsa" -H ubuntu@example.com
|
|
@task
|
|
def run_loadtest(host, t=90):
|
|
sudo("loadtest -c 10 -t {t} {h}".format(h=host, t=t))
|
|
|
|
# Run current loadtesting setup
|
|
# example usage: $ fab run_loadtest:http://127.0.0.1,rps=10 -i "id_rsa" -H ubuntu@example.com
|
|
@task
|
|
def run_loadtest_rps(host, t=90, rps=200):
|
|
sudo("loadtest -c 10 --rps {rps} -t {t} {h}".format(h=host, t=t, rps=rps))
|
|
|
|
|
|
# Task that Andrew used for loadtesting earlier on
|
|
@task
|
|
def setup_tester():
|
|
sudo("apt-get update && apt-get install -y apache2-utils python3-pip")
|
|
sudo("pip3 -U pip autobahn twisted")
|
|
sudo("rm -rf /srv/channels")
|
|
sudo("git clone https://github.com/andrewgodwin/channels.git /srv/channels/")
|
|
|
|
|
|
@task
|
|
def shell():
|
|
sudo("bash")
|