-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from 101t/4.0.0
code refactor, re-design django-aio, bug fixes, adding swagger, READM…
- Loading branch information
Showing
495 changed files
with
661 additions
and
29,362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.git/ | ||
.gitignore | ||
.gitattributes | ||
.vscode/ | ||
.github/ | ||
.env | ||
.travis.yml | ||
Dockerfile | ||
|
||
.cache | ||
*.md | ||
!README*.md | ||
env/ | ||
venv/ | ||
|
||
cache/ | ||
logs/ | ||
public/ | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM python:3.11-slim | ||
|
||
# disable debian interactive | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV PIP_NO_CACHE_DIR 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
ENV APP_DIR /app | ||
ENV APP_USER app | ||
|
||
RUN apt-get update && apt-get -y upgrade | ||
|
||
RUN apt-get install --no-install-recommends -y \ | ||
python3-dev python3-wheel python3-setuptools virtualenv \ | ||
build-essential nano gcc curl \ | ||
libpq-dev libpq5 telnet \ | ||
libjemalloc2 | ||
|
||
RUN apt-get clean autoclean && apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
||
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 | ||
|
||
RUN useradd -m -d ${APP_DIR} -U -r -s /bin/bash ${APP_USER} | ||
|
||
USER ${APP_USER} | ||
|
||
WORKDIR ${APP_DIR} | ||
|
||
RUN python -m venv /app/env | ||
|
||
ENV PATH="$APP_DIR/env/bin:$PATH" | ||
|
||
RUN mkdir media static logs | ||
|
||
COPY requirements.txt . | ||
|
||
RUN pip install -U pip wheel | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
COPY --chown=$APP_USER . . | ||
|
||
ENV PYTHONPATH "${PYTHONPATH}:/app" | ||
|
||
RUN chmod +x entrypoint.sh | ||
RUN chmod +x entrypoint-celery.sh | ||
|
||
RUN chown -R app: $APP_DIR | ||
|
||
ENTRYPOINT ["bash", "entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Variables definitions | ||
# ----------------------------------------------------------------------------- | ||
|
||
TIMEOUT ?= 60 | ||
|
||
# Determine the OS platform (Windows or Linux) | ||
ifeq ($(OS),Windows_NT) | ||
SHELL := cmd.exe | ||
RM := del /Q | ||
EXE := .exe | ||
else | ||
SHELL := /bin/bash | ||
RM := rm -rf | ||
EXE := | ||
endif | ||
|
||
|
||
# Target section and Global definitions | ||
# ----------------------------------------------------------------------------- | ||
.PHONY: all clean test install run deploy down | ||
|
||
all: clean test install run deploy down | ||
|
||
test: | ||
python -m pytest tests -vv --show-capture=all | ||
|
||
install: generate_dot_env | ||
pip install --upgrade pip wheel | ||
pip install -r requirements.txt | ||
|
||
run: | ||
PYTHONPATH=. python manage.py runserver 0.0.0.0:8000 | ||
|
||
run_uvicorn: | ||
PYTHONPATH=. uvicorn config.asgi:application --reload --host 0.0.0.0 --port 8000 | ||
|
||
run_celery: | ||
PYTHONPATH=. celery -A config worker --max-tasks-per-child 1 -l info | ||
|
||
run_channels: | ||
PYTHONPATH=. daphne config.asgi:application -b 0.0.0.0 -p 9000 | ||
|
||
run_docker: generate_dot_env | ||
docker-compose build | ||
docker-compose up | ||
|
||
generate_dot_env: | ||
@if [ ! -e .env ]; then \ | ||
cp sample.env .env; \ | ||
fi | ||
|
||
make_migrations: | ||
python manage.py makemigrations | ||
|
||
migrate: | ||
python manage.py migrate | ||
|
||
clean: | ||
$(RM) *.pyc | ||
$(RM) -r __pycache__ | ||
$(RM) Thumbs.db | ||
$(RM) *~ | ||
$(RM) .cache | ||
$(RM) build | ||
$(RM) dist | ||
$(RM) *.egg-info | ||
$(RM) htmlcov | ||
$(RM) .tox/ | ||
$(RM) -r docs/_build | ||
$(RM) .env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
from celery import Celery | ||
from celery.utils.log import get_task_logger | ||
from django.conf import settings | ||
|
||
logger = get_task_logger(__name__) | ||
|
||
__all__ = ['app', 'debug_task', 'revoke_task', 'clear_tasks'] | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.dev") | ||
|
||
app = Celery( | ||
'main', | ||
backend=settings.REDIS_URI, | ||
broker=settings.REDIS_URI, | ||
) | ||
app.config_from_object('django.conf:settings', namespace='CELERY') | ||
app.conf.broker_connection_retry_on_startup = True | ||
|
||
CELERY_TIMEZONE = settings.TIME_ZONE | ||
CELERY_ENABLE_UTC = bool(os.environ.get('CELERY_ENABLE_UTC', default=False)) | ||
|
||
|
||
@app.task(bind=True) | ||
def debug_task(self): | ||
logger.info('Request: {0!r}'.format(self.request)) # pragma: no cover | ||
|
||
|
||
def revoke_task(task_id): | ||
app.control.revoke(task_id) | ||
|
||
|
||
def clear_tasks(): | ||
return app.control.purge() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import os | ||
|
||
DEFAULT_RETRY_DELAY = int(os.environ.get('DEFAULT_RETRY_DELAY', default=5)) # 15 seconds | ||
MAX_RETRIES = int(os.environ.get('MAX_RETRIES', default=5)) |
Oops, something went wrong.