Update config and work on shell/docker
This commit is contained in:
parent
4cfc800f8c
commit
1b1601e4c4
@ -12,6 +12,7 @@ LABEL maintainer="parker <mailto:contact@pkrm.dev>"
|
|||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN chmod +x linklogger.sh
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y nginx && \
|
RUN apt-get update && apt-get install -y nginx && \
|
||||||
@ -22,4 +23,4 @@ COPY --from=build-ui /app/dist /usr/share/nginx/html
|
|||||||
# Replace the default site with the LinkLogger config
|
# Replace the default site with the LinkLogger config
|
||||||
COPY nginx.conf /etc/nginx/sites-enabled/default
|
COPY nginx.conf /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
CMD service nginx start && python -u linklogger.py
|
CMD ["./linklogger.sh"]
|
@ -1,7 +1,6 @@
|
|||||||
import jsonschema
|
import jsonschema
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
from colorlog import ColoredFormatter
|
from colorlog import ColoredFormatter
|
||||||
|
|
||||||
@ -66,7 +65,9 @@ config:
|
|||||||
"`config.yaml` was not found, a template has been created."
|
"`config.yaml` was not found, a template has been created."
|
||||||
" Please fill out the necessary information and restart."
|
" Please fill out the necessary information and restart."
|
||||||
)
|
)
|
||||||
sys.exit()
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Validate the options within config.yaml
|
# Validate the options within config.yaml
|
||||||
@ -78,7 +79,7 @@ def validate_config(file_contents):
|
|||||||
jsonschema.validate(config, schema)
|
jsonschema.validate(config, schema)
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
LOG.error(e.message)
|
LOG.error(e.message)
|
||||||
sys.exit()
|
return False
|
||||||
|
|
||||||
# Make IP_TO_LOCATION a boolean
|
# Make IP_TO_LOCATION a boolean
|
||||||
IP_TO_LOCATION = bool(config["config"]["ip_to_location"])
|
IP_TO_LOCATION = bool(config["config"]["ip_to_location"])
|
||||||
|
20
dev.sh
Executable file
20
dev.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# If on Linux or MacOS - check tmux
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
python3 linklogger.py &
|
||||||
|
cd app || return
|
||||||
|
yarn dev
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If on Windows
|
||||||
|
if [[ "$OSTYPE" == "msys" ]]; then
|
||||||
|
python3 linklogger.py &
|
||||||
|
cd app || return
|
||||||
|
yarn dev
|
||||||
|
# echo -e "This script is not supported on Windows. Please run the API and UI manually."
|
||||||
|
# echo -e "\t1. Install node.js, yarn, python3, and pip"
|
||||||
|
# echo -e "\t2. Run 'pip install -r requirements.txt' in the root directory"
|
||||||
|
# echo -e "\t3. Run 'python3 linklogger.py' in the root directory"
|
||||||
|
# echo -e "\t4. Run 'cd app' and then 'yarn dev'"
|
||||||
|
# exit 1
|
||||||
|
fi
|
@ -8,5 +8,5 @@ from database import Base, engine
|
|||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
config.load_config()
|
if config.load_config():
|
||||||
uvicorn.run(app, port=5252)
|
uvicorn.run(app, port=5252)
|
||||||
|
6
linklogger.sh
Normal file
6
linklogger.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Start nginx in the background
|
||||||
|
service nginx start
|
||||||
|
|
||||||
|
# Run the Python script
|
||||||
|
python -u linklogger.py
|
Loading…
x
Reference in New Issue
Block a user