diff options
| author | 2019-09-30 17:58:29 +0200 | |
|---|---|---|
| committer | 2019-09-30 17:58:29 +0200 | |
| commit | f47351c1c2b3ac644b695bca03d74469412024f5 (patch) | |
| tree | fda470c0b1524679594db1a0bae20c7dab57c570 | |
| parent | Add jump url (diff) | |
| parent | Adjust development workflow inline with new `site` changes. (#464) (diff) | |
Merge branch 'master' into reminder-up
Diffstat (limited to '')
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | bot/__init__.py | 13 | ||||
| -rw-r--r-- | docker-compose.yml | 26 | 
3 files changed, 28 insertions, 13 deletions
| @@ -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 | 
