Permalink
Browse files

It's alive! :D

  • Loading branch information...
WhiteHalmos committed Sep 13, 2015
1 parent 7bf71a4 commit c852ae0e4aa267fdc50b5315ee09cca2c3936ec5
@@ -1,3 +1,4 @@
*.pyc
webapp/session/*
dbbackups/*
matchlog/*
@@ -3,19 +3,13 @@ dbdata:
entrypoint: /bin/echo
image: postgres:9.4
db:
env_file: ./postgres/db.env
environment:
- POSTGRES_USER=robot
image: postgres:9.4
volumes:
- ./postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql
- ./sql/schema.sql:/docker-entrypoint-initdb.d/schema.sql
volumes_from:
- dbdata
dbrun:
command: One-off database runner for rgserver
entrypoint: /bin/echo
env_file: ./postgres/db.env
image: postgres:9.4
links:
- db
matchmaker:
build: matchmaker
links:
@@ -39,3 +33,13 @@ server:
- ./matchlog:/usr/local/matchlog
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./static:/usr/local/static
run:
command: One-off runner for rgserver
entrypoint: /bin/echo
image: postgres:9.4
links:
- db
volumes:
- ./matchlog:/matchlog
- ./dbbackups:/dbbackups
- ./sql:/sql
BIN +51 Bytes (100%) matchlog/.gitkeep
Binary file not shown.
@@ -1,11 +1,26 @@
server {
listen 80 default_server;
location /robots.txt {
alias /usr/local/static/robots.txt;
}
location /favicon.ico {
expires 168h;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
alias /usr/local/static/favicon.png;
}
location /static {
expires 168h;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
alias /usr/local/static;
}
location /matchlog {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
default_type text/plain;
alias /usr/local/matchlog;
}

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,11 @@
#!/bin/bash
# Run sql
docker-compose run --no-deps -e PGOPTIONS='--client-min-messages=warning' --entrypoint psql run -h db -U robot -d robotgame -q -1 -f /sql/daily.sql
# Backup dbs
docker-compose run --no-deps --entrypoint pg_dump run -h db -U robot -d robotgame --format=c -s -f /dbbackups/`date +\%Y-\%m-\%d`-robotgame-schema
docker-compose run --no-deps --entrypoint pg_dump run -h db -U robot -d robotgame --format=c -a -T history -f /dbbackups/`date +\%Y-\%m-\%d`-robotgame-data
# Compress matches
# Note that -mtime +1 matches at least 2 days ago
# Keep for 2 weeks so fewer 404s for Google
docker-compose run --no-deps --entrypoint find run /matchlog/ -mtime +13 -delete;
docker-compose run --no-deps --entrypoint find run /matchlog/ -not -path "/matchlog/" -not -path "*/.gitkeep" -not -name "*.gz" -exec gzip -6 "{}" \;
@@ -0,0 +1,3 @@
#!/bin/bash
# Run sql
docker-compose run --no-deps -e PGOPTIONS='--client-min-messages=warning' --entrypoint psql run -h db -U robot -d robotgame -q -1 -f /sql/hourly.sql
@@ -0,0 +1,2 @@
#!/bin/bash
docker-compose run --entrypoint psql run -h db -U robot -d robotgame
@@ -0,0 +1,2 @@
update users set challenges=0;
update robots set last_rating=rating where rating is not NULL;
@@ -0,0 +1,30 @@
DO $$
DECLARE
one_week_ago integer;
one_month_ago integer;
BEGIN
/* Update trophies */
update robots set fast=FALSE where fast;
update robots set fast=TRUE where id in
(select id from robots
where compiled and passed and not disabled and rating is not Null
and time < 2
order by rating desc limit 10);
update robots set short=FALSE where short;
update robots set short=TRUE where id in
(select id from robots
where compiled and passed and not disabled and rating is not Null
and length(compiled_code) < 1000
order by rating desc limit 10);
/* Reset automatch */
one_month_ago := round(extract(epoch from now()) - 60 * 60 * 24 * 30);
update robots set automatch = 'f' from users where robots.user_id=users.id
and automatch
and users.last_active < one_month_ago;
/* Delete history */
one_week_ago := round(extract(epoch from now()) - 60 * 60 * 24 * 7);
delete from history where timestamp < one_week_ago;
END $$;
File renamed without changes.

0 comments on commit c852ae0

Please sign in to comment.