remove
This commit is contained in:
parent
9e7c4345ed
commit
f400b7d0c9
@ -36,6 +36,23 @@ services:
|
|||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
|
remove:
|
||||||
|
image: mathwave/sprint-repo:battleship-back
|
||||||
|
networks:
|
||||||
|
- battleship-net
|
||||||
|
environment:
|
||||||
|
DB_HOST: "pg.develop.sprinthub.ru"
|
||||||
|
DB_PASSWORD: $DB_PASSWORD_DEV
|
||||||
|
DEBUG: "true"
|
||||||
|
command: ./manage.py remove
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
restart_policy:
|
||||||
|
condition: any
|
||||||
|
update_config:
|
||||||
|
parallelism: 1
|
||||||
|
order: start-first
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
battleship-net:
|
battleship-net:
|
||||||
driver: overlay
|
driver: overlay
|
||||||
|
@ -24,9 +24,9 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- battleship-net
|
- battleship-net
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: "pg.develop.sprinthub.ru"
|
DB_HOST: "pg.sprinthub.ru"
|
||||||
DB_PASSWORD: $DB_PASSWORD_DEV
|
DB_PASSWORD: $DB_PASSWORD_PROD
|
||||||
DEBUG: "true"
|
DEBUG: "false"
|
||||||
command: bash -c "./manage.py migrate && ./manage.py runserver 0.0.0.0:8000"
|
command: bash -c "./manage.py migrate && ./manage.py runserver 0.0.0.0:8000"
|
||||||
deploy:
|
deploy:
|
||||||
mode: replicated
|
mode: replicated
|
||||||
|
0
battleship/management/__init__.py
Normal file
0
battleship/management/__init__.py
Normal file
0
battleship/management/commands/__init__.py
Normal file
0
battleship/management/commands/__init__.py
Normal file
15
battleship/management/commands/remove.py
Normal file
15
battleship/management/commands/remove.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from datetime import timedelta
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from django.core.management import BaseCommand
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from battleship.models import Game
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
while True:
|
||||||
|
print('deleting old games')
|
||||||
|
Game.objects.filter(last_move_ts__lte=timezone.now() - timedelta(days=1)).delete()
|
||||||
|
sleep(60 * 60 * 24)
|
@ -2,6 +2,8 @@ from django.http import JsonResponse
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from battleship.models import Game, Player, generate_token
|
from battleship.models import Game, Player, generate_token
|
||||||
|
|
||||||
|
|
||||||
@ -74,6 +76,7 @@ def shoot(request):
|
|||||||
else:
|
else:
|
||||||
new_symb = '.'
|
new_symb = '.'
|
||||||
player.game.turn = (1 - player.game.turn)
|
player.game.turn = (1 - player.game.turn)
|
||||||
|
player.game.last_move_ts = timezone.now()
|
||||||
player.game.save()
|
player.game.save()
|
||||||
if pos == 0:
|
if pos == 0:
|
||||||
player2.field = new_symb + player2.field[1:]
|
player2.field = new_symb + player2.field[1:]
|
||||||
|
@ -23,7 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
SECRET_KEY = 'django-insecure-$x=irhk3ts1ae%b+kpr+g%mk3v$eb++^0eh(eg0)+-hb+ane82'
|
SECRET_KEY = 'django-insecure-$x=irhk3ts1ae%b+kpr+g%mk3v$eb++^0eh(eg0)+-hb+ane82'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = os.getenv("DEBUG", "true") == "true"
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user