Compare commits

...

4 Commits

9 changed files with 69 additions and 8 deletions

1
description Normal file
View File

@ -0,0 +1 @@
Track fear and phase in multiplayer games of the board game Spirit Island.

View File

@ -0,0 +1,16 @@
# Based on https://docs.gunicorn.org/en/stable/deploy.html#systemd
[Service]
ExecStart=/usr/bin/gunicorn3 fear_tracker_site.asgi:application --config=/home/anyoneeb/sites/apps/fear-tracker/gunicorn.conf.py
ExecReload=/bin/kill -s HUP $MAINPID
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=fear-tracker
User=fear-tracker
Group=fear-tracker
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,11 @@
[Service]
ExecStart=/usr/bin/uwsgi --ini /home/anyoneeb/sites/apps/fear-tracker/uwsgi.ini
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=fear-tracker
User=fear-tracker
Group=fear-tracker
[Install]
WantedBy=multi-user.target

View File

@ -1,7 +1,12 @@
from channels.http import AsgiHandler
from channels.routing import ProtocolTypeRouter, URLRouter
import django
from django.conf.urls import url
from django.core.asgi import get_asgi_application
# TODO Importing views breaks if django.setup() isn't called first...
# ... but this isn't the way this is supposed to work.
django.setup()
from . import views
@ -9,8 +14,8 @@ application = ProtocolTypeRouter({
"http": URLRouter([
url(r'^(?P<access_code>[a-zA-Z]{6})/', URLRouter([
url(r"status/(?P<hashcode>[a-z0-9]{64})/",
views.StatusLongPollConsumer, name='status'),
views.StatusLongPollConsumer.as_asgi(), name='status'),
])),
url(r"", AsgiHandler),
url(r"", get_asgi_application()),
]),
})

View File

@ -377,7 +377,7 @@ class StatusLongPollConsumer(AsyncHttpConsumer):
async def fear_tracker_hashcode_seen(self, event):
if self.hashcode != event["hashcode"]:
if event["status_string"]:
if "status_string" in event and event["status_string"]:
body = event["status_string"].encode('utf-8')
await self.send_response(200, body)
await self.disconnect()

View File

@ -3,10 +3,9 @@ ASGI entrypoint. Configures Django and then runs the application
defined in the ASGI_APPLICATION setting.
"""
import os
import django
from channels.routing import get_default_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fear_tracker_site.settings")
import fear_tracker.routing
django.setup()
application = get_default_application()
application = fear_tracker.routing.application

14
gunicorn.conf.py Normal file
View File

@ -0,0 +1,14 @@
import multiprocessing
bind = "127.0.0.1:8043"
worker_class = "uvicorn.workers.UvicornWorker"
workers = multiprocessing.cpu_count() * 2 + 1
chdir = "/home/anyoneeb/sites/apps/fear-tracker"
raw_env = "DJANGO_SETTINGS_MODULE=fear_tracker_site.local_settings"
proc_name = "gnuicorn-fear-tracker"
pidfile = "/tmp/gnuicorn-fear-tracker.pid"
user = "fear-tracker"
group = "fear-tracker"
max_requests=5000
max_requests_jitter=100
preload_app=True

1
source Normal file
View File

@ -0,0 +1 @@
https://git.aweirdimagination.net/perelman/fear_tracker

14
uwsgi.ini Normal file
View File

@ -0,0 +1,14 @@
[uwsgi]
socket=127.0.0.1:8043
mount = /fear-tracker=fear_tracker_site.wsgi:application
manage-script-name = true
chdir=/home/anyoneeb/sites/apps/fear-tracker
plugin=python3
module=fear_tracker_site.wsgi:application
env=DJANGO_SETTINGS_MODULE=fear_tracker_site.local_settings
master=True
pidfile=/tmp/fear-tracker-master.pid
vacuum=True
max-requests=5000
uid=fear-tracker
gid=fear-tracker