Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from mariadb:10.5

ENV PATH_TO_STATS=/stats/

COPY . $PATH_TO_STATS

RUN apt-get update && \
apt install cron curl wget jq -y && \
apt-get clean

WORKDIR $PATH_TO_STATS

ENTRYPOINT /stats/entrypoint.sh
6 changes: 6 additions & 0 deletions config.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ PATH_TO_STATS=/home/dkmur/temp/Stats/
DEFINED_SCAN_AREAS='Amsterdam, London, Paris'
DEFAULT_AREA=London

## Quest Settings ##
QUEST_START='02:00:00'
QUEST_END='06:00:00'
QUEST_CLEAN_HR=6
QUEST_CLEAN_MIN=13

## Grafana ##
DataSource=pogodb

Expand Down
2 changes: 1 addition & 1 deletion crontab.txt.default
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
7 0 * * * cd pathToStatssql_cron/ && mysql userpass < 1440_worker.sql
9 0 * * 1 cd pathToStatssql_cron/ && mysql userpass < 10080_worker.sql
## Cleanup spawnpoints discovered during Quest hours
# 13 6 * * 1 cd pathToStatssql_cron/ && mysql userpass < quest_spawn_cleanup.sql
# QMIN QHR * * 1 cd pathToStatssql_cron/ && mysql userpass < quest_spawn_cleanup.sql
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# This is a k8s concession, since you can not map a volume to a specific
# file, you must map an entire directory. This simply moves the file to
# where the stats cronjobs are expecting to find it.
cp /stats/config/config.ini /stats/config.ini

# Initialization is idempotent, and creates files which will die with the
# container.
/stats/settings.run

if "$QUEST_CLEAN"
then
sed -i '$ s/# //g' /stats/crontab.txt
fi

crontab /stats/crontab.txt
crontab -l

# Run the cron deaemon
/usr/sbin/cron -f -L /dev/stdout
2 changes: 2 additions & 0 deletions settings.run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cp crontab.txt.default crontab.txt
PATH_TO_STATS2=$(sed 's@/@\\/@g' <<< $PATH_TO_STATS)
cd $PATH_TO_STATS && sed -i "s/pathToStats/$PATH_TO_STATS2/g" *.txt
cd $PATH_TO_STATS && sed -i "s/STATS_DB/$STATS_DB/g" *.txt
cd $PATH_TO_STATS && sed -i "s/QMIN/$QUEST_CLEAN_MIN/g" *.txt
cd $PATH_TO_STATS && sed -i "s/QHR/$QUEST_CLEAN_HR/g" *.txt

if [ -z "$SQL_password" ]
then
Expand Down
8 changes: 4 additions & 4 deletions sql_cron/quest_spawn_cleanup.sql.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ select spawnpoint,latitude,longitude,spawndef,earliest_unseen,last_scanned,first
from rmdb.trs_spawn
where
date(first_detection) = curdate() and
time(first_detection) >= '02:00:00' and
time(first_detection) <= '06:00:00'
time(first_detection) >= 'queststart' and
time(first_detection) <= 'questend'
;
-- remove from trs_spawn
delete
from rmdb.trs_spawn
where
date(first_detection) = curdate() and
time(first_detection) >= '02:00:00' and
time(first_detection) <= '06:00:00'
time(first_detection) >= 'queststart' and
time(first_detection) <= 'questend'
;

-- daily cleanup spawns not seen for 5 days
Expand Down