aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar scragly <[email protected]>2019-09-30 20:50:03 +1000
committerGravatar GitHub <[email protected]>2019-09-30 20:50:03 +1000
commit71a3ac9382851845dcb26609d64299bd69b0f0f5 (patch)
tree2949aaf1d16863224d3717729947fe9b35270ae7
parentMerge pull request #460 from python-discord/help-fix (diff)
parentRemove temp instructions, add link to contrib guide on website. (diff)
Adjust development workflow inline with new `site` changes. (#464)
Adjust development workflow inline with new `site` changes.
-rw-r--r--README.md2
-rw-r--r--bot/__init__.py13
-rw-r--r--docker-compose.yml26
3 files changed, 28 insertions, 13 deletions
diff --git a/README.md b/README.md
index ae3288dbf..7a7f1b992 100644
--- a/README.md
+++ b/README.md
@@ -9,3 +9,5 @@
This project is a Discord bot specifically for use with the Python Discord server. It provides numerous utilities
and other tools to help keep the server running like a well-oiled machine.
+
+Read the [Contributing Guide](https://pythondiscord.com/pages/contributing/bot/) on our website if you're interested in helping out.
diff --git a/bot/__init__.py b/bot/__init__.py
index d094e8c13..4a2df730d 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -2,6 +2,7 @@ import logging
import os
import sys
from logging import Logger, StreamHandler, handlers
+from pathlib import Path
from logmatic import JsonFormatter
@@ -30,22 +31,20 @@ logging_handlers = []
# We can't import this yet, so we have to define it ourselves
DEBUG_MODE = True if 'local' in os.environ.get("SITE_URL", "local") else False
+LOG_DIR = Path("logs")
+LOG_DIR.mkdir(exist_ok=True)
if DEBUG_MODE:
logging_handlers.append(StreamHandler(stream=sys.stdout))
- json_handler = logging.FileHandler(filename="log.json", mode="w")
+ json_handler = logging.FileHandler(filename=Path(LOG_DIR, "log.json"), mode="w")
json_handler.formatter = JsonFormatter()
logging_handlers.append(json_handler)
else:
- logdir = "log"
- logfile = logdir+os.sep+"bot.log"
+ logfile = Path(LOG_DIR, "bot.log")
megabyte = 1048576
- if not os.path.exists(logdir):
- os.makedirs(logdir)
-
filehandler = handlers.RotatingFileHandler(logfile, maxBytes=(megabyte*5), backupCount=7)
logging_handlers.append(filehandler)
@@ -55,7 +54,7 @@ else:
logging.basicConfig(
- format="%(asctime)s pd.beardfist.com Bot: | %(name)33s | %(levelname)8s | %(message)s",
+ format="%(asctime)s Bot: | %(name)33s | %(levelname)8s | %(message)s",
datefmt="%b %d %H:%M:%S",
level=logging.TRACE if DEBUG_MODE else logging.INFO,
handlers=logging_handlers
diff --git a/docker-compose.yml b/docker-compose.yml
index 4b0dcff35..9684a3c62 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,8 +7,6 @@ version: "3.7"
services:
postgres:
image: postgres:11-alpine
- ports:
- - "127.0.0.1:7777:5432"
environment:
POSTGRES_DB: pysite
POSTGRES_PASSWORD: pysite
@@ -16,15 +14,31 @@ services:
web:
image: pythondiscord/site:latest
- command: >
- bash -c "echo \"from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin', 'admin') if not User.objects.filter(username='admin').exists() else print('Admin user already exists')\" | python manage.py shell
- && ./manage.py runserver 0.0.0.0:8000"
+ command: ["run", "--debug"]
+ networks:
+ default:
+ aliases:
+ - api.web
+ - admin.web
+ - staff.web
ports:
- "127.0.0.1:8000:8000"
depends_on:
- postgres
environment:
DATABASE_URL: postgres://pysite:pysite@postgres:5432/pysite
- DEBUG: "true"
SECRET_KEY: suitable-for-development-only
STATIC_ROOT: /var/www/static
+
+ bot:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ volumes:
+ - ./logs:/bot/logs
+ - .:/bot:ro
+ depends_on:
+ - web
+ environment:
+ BOT_TOKEN: ${BOT_TOKEN}
+ BOT_API_KEY: badbot13m0n8f570f942013fc818f234916ca531