diff --git a/README.md b/README.md index 50b22af..e4afb0e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Please also, in a developer's text editor e.g. NotePad++ or Microsoft Visual Stu * Register for [DuckDNS](https://www.duckdns.org/) and have your subdomain name and token ready * Make sure ports 80 and 443 are accessible on your host machine and your machine has a connection to the Internet * Copy .env.template to .env with `cp .env.template .env` *DO NOT COMMIT AND PUSH .env TO A PUBLIC GIT REPOSITORY UNLESS YOU WANT TO GET HACKED!!!* -* Edit the files .env, .configs/traefik.toml, and .configs/grafana.ini, updating configuration values with your desired configuration +* Edit the files .env and .configs/grafana.ini, updating configuration values with your desired configuration * Run `docker-compose config` from this directory to doublecheck that docker-compose.yaml file contains no syntax errors and that all your options from .env were correctly filled in ## Creating Your Stack @@ -32,6 +32,7 @@ To Stop or (re)Start a container in your stack without removing it, run `docker- Run the following commands to update the images your containers use and recreate/restart the containers using them ```bash +docker-compose build docker-compose pull docker-compose up -d docker image prune -f diff --git a/gatecounter-scripts/PIRdbWriteGate.py b/gatecounter-scripts/PIRdbWriteGate.py index c23085c..c96a056 100755 --- a/gatecounter-scripts/PIRdbWriteGate.py +++ b/gatecounter-scripts/PIRdbWriteGate.py @@ -7,7 +7,7 @@ import sys from argparse import ArgumentParser from concurrent.futures import ThreadPoolExecutor, CancelledError, wait from datetime import datetime -from queue import Queue +from queue import SimpleQueue import RPi.GPIO as GPIO @@ -30,11 +30,11 @@ Base = declarative_base() class PIR_Detection(Base): __tablename__ = "PIRSTATS" - time = Column('datetime', DateTime, nullable=False, primary_key=True) + timestamp = Column('timestamp', DateTime, nullable=False, primary_key=True) count = Column('count', Integer, nullable=False) -Detection=collections.namedtuple("Detection", ['time','count']) +Detection=collections.namedtuple("Detection", ['timestamp','count']) class PIRgate: def __init__(self, hostname, username, password, database): @@ -46,7 +46,7 @@ class PIRgate: GPIO.setup(self.PIR_PIN, GPIO.IN) # End GPIO setup self._pool=ThreadPoolExecutor() - self._detection_queue=Queue() + self._detection_queue=SimpleQueue() if not hostname: stdout,stderr = subprocess.Popen(['docker', 'inspect', @@ -80,7 +80,7 @@ class PIRgate: try: detection = self._detection_queue.get() session = self.Session() - session.add(PIR_Detection(time=detection.datetime, count=detection.count)) + session.add(PIR_Detection(timestamp=detection.timestamp, count=detection.count)) except KeyboardInterrupt: session.rollback() raise diff --git a/sql/db-init.sql b/sql/db-init.sql deleted file mode 100644 index e748c72..0000000 --- a/sql/db-init.sql +++ /dev/null @@ -1,17 +0,0 @@ -create table if not exists PIRSTATS ( -datetime DATETIME not NULL, -gatecount INT, -PRIMARY KEY (datetime) -); - -create table if not exists ULTRASTATS ( -datetime DATETIME not NULL, -gatecount INT, -PRIMARY KEY (datetime) -); - -create table if not exists LDRSTATS ( -datetime DATETIME not NULL, -gatecount INT, -PRIMARY KEY (datetime) -); \ No newline at end of file