diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6e82e9c..0000000 --- a/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# Base image -FROM python:3.11-slim - -# Environment vars -ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PRODUCTION=true - -# Working directory -WORKDIR /app - -# Install system dependencies -RUN apt-get update && \ - apt-get install -y git && \ - rm -rf /var/lib/apt/lists/* - -# Copy dependency file -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt - -# Copy entire app -COPY . . - -# Ensure uploads folder exists -RUN mkdir -p uploads - -# Expose the port Flask uses -EXPOSE 5000 - -# Start the app -CMD ["python", "app.py"] diff --git a/ROADMAP.md b/ROADMAP.md index 52052cb..0fe0162 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -6,6 +6,11 @@ ### Phase 0 - [x] Remove docker files (Dropping official docker support) +<<<<<<< HEAD + +- [x] Update README.md to be current. +======= +>>>>>>> 2a414e62cf21b47eb5976535fe1499e02d561f4c - [x] Add roadmap.md to repo @@ -15,7 +20,7 @@ - [x] Create /paccrypt_algos/ folder -- [ ] Builder better start, stop and restart scripts both prod and dev (Universal) +- [x] Builder better start, stop and restart scripts both prod and dev (Linux Only) - [ ] Add a button in the admin panel to switch to and from prod and dev modes - **Saving for UI Revamp** diff --git a/app.py b/app.py index 2c8c68e..886dc43 100644 --- a/app.py +++ b/app.py @@ -31,14 +31,14 @@ app.secret_key = os.getenv("FLASK_SECRET", os.urandom(24)) CORS(app, origins=["https://pdf.unnaturalll.dev"]) # ===== Constants ===== -ADMIN_CRED_FILE = 'admin_creds.json' -ADMIN_KEY_FILE = 'admin_key.key' -ADMIN_LOG_FILE = 'admin_logs.enc' -SETTINGS_FILE = 'settings.json' +ADMIN_CRED_FILE = 'application_data/admin_creds.json' +ADMIN_KEY_FILE = 'application_data/admin_key.key' +ADMIN_LOG_FILE = 'application_data/admin_logs.enc' +SETTINGS_FILE = 'application_data/settings.json' ALPHABET = list('abcdefghijklmnopqrstuvwxyz') DEFAULT_SETTINGS = { - "upload_folder": "uploads", + "upload_folder": "pacshare", "max_file_age_days": 14, "max_file_size_bytes": 25 * 1024 * 1024 * 1024 # 25GB } diff --git a/application_data/control_scripts/restart_dev.py b/application_data/control_scripts/restart_dev.py new file mode 100644 index 0000000..93344d4 --- /dev/null +++ b/application_data/control_scripts/restart_dev.py @@ -0,0 +1,46 @@ +import os +import subprocess +import signal +import time +import sys +import psutil + +APP_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../app.py")) + +DEBUG = True + +def log(msg): + if DEBUG: + print(msg) + +def start_dev(): + env = os.environ.copy() + env["PRODUCTION"] = "false" + return subprocess.Popen( + ["python3", APP_PATH], + env=env, + preexec_fn=os.setsid, + stdout=sys.stdout, + stderr=sys.stderr + ) + +def stop_by_port(port=5000): + for proc in psutil.process_iter(["pid", "name"]): + try: + for conn in proc.connections(kind="inet"): + if conn.laddr.port == port: + log(f"[*] Killing process {proc.pid} using port {port}") + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + return + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + log(f"[!] No process found using port {port}") + +def main(): + log("[*] Restarting PacCrypt in DEVELOPMENT mode...") + stop_by_port() + time.sleep(1) + start_dev() + +if __name__ == "__main__": + main() diff --git a/application_data/control_scripts/restart_prod.py b/application_data/control_scripts/restart_prod.py new file mode 100644 index 0000000..95bd777 --- /dev/null +++ b/application_data/control_scripts/restart_prod.py @@ -0,0 +1,40 @@ +import os +import subprocess +import signal +import time +import sys +import psutil + +APP_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../app.py")) + +def start_prod(): + env = os.environ.copy() + env["PRODUCTION"] = "true" + return subprocess.Popen( + ["python3", APP_PATH], + env=env, + preexec_fn=os.setsid, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + +def stop_by_port(port=5000): + for proc in psutil.process_iter(["pid", "name"]): + try: + for conn in proc.connections(kind="inet"): + if conn.laddr.port == port: + print(f"[*] Killing process {proc.pid} using port {port}") + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + return + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + print(f"[!] No process found using port {port}") + +def main(): + print("[*] Restarting PacCrypt in PRODUCTION mode with Waitress...") + stop_by_port() + time.sleep(1) + start_prod() + +if __name__ == "__main__": + main() diff --git a/application_data/control_scripts/start_dev.py b/application_data/control_scripts/start_dev.py new file mode 100644 index 0000000..e72b8e2 --- /dev/null +++ b/application_data/control_scripts/start_dev.py @@ -0,0 +1,30 @@ +import os +import subprocess +import time +import sys + +APP_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../app.py")) + +DEBUG = True + +def log(msg): + if DEBUG: + print(msg) + +def start_dev(): + env = os.environ.copy() + env["PRODUCTION"] = "false" + return subprocess.Popen( + ["python3", APP_PATH], + env=env, + preexec_fn=os.setsid, + stdout=sys.stdout, + stderr=sys.stderr + ) + +def main(): + log("[*] Starting PacCrypt in DEVELOPMENT mode...") + start_dev() + +if __name__ == "__main__": + main() diff --git a/application_data/control_scripts/start_prod.py b/application_data/control_scripts/start_prod.py new file mode 100644 index 0000000..2bc9275 --- /dev/null +++ b/application_data/control_scripts/start_prod.py @@ -0,0 +1,24 @@ +import os +import subprocess +import time +import sys + +APP_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../app.py")) + +def start_prod(): + env = os.environ.copy() + env["PRODUCTION"] = "true" + return subprocess.Popen( + ["python3", APP_PATH], + env=env, + preexec_fn=os.setsid, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + +def main(): + print("[*] Starting PacCrypt in PRODUCTION mode with Waitress...") + start_prod() + +if __name__ == "__main__": + main() diff --git a/application_data/control_scripts/stop.py b/application_data/control_scripts/stop.py new file mode 100644 index 0000000..0d20153 --- /dev/null +++ b/application_data/control_scripts/stop.py @@ -0,0 +1,27 @@ +import psutil +import os +import signal + +DEBUG = True + +def log(msg): + if DEBUG: + print(msg) + +def stop_by_port(port=5000): + for proc in psutil.process_iter(["pid", "name"]): + try: + for conn in proc.connections(kind="inet"): + if conn.laddr.port == port: + log(f"[*] Killing process {proc.pid} using port {port}") + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + return + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + log(f"[!] No process found using port {port}") + +def main(): + stop_by_port() + +if __name__ == "__main__": + main() diff --git a/requirements.txt b/application_data/requirements.txt similarity index 74% rename from requirements.txt rename to application_data/requirements.txt index 6c080c8..83ce7fe 100644 --- a/requirements.txt +++ b/application_data/requirements.txt @@ -8,4 +8,4 @@ werkzeug==3.0.1 psutil>=5.9.0,<6.0.0 # nginx - Only needed for Nginx integration, not installed via pip -# Run pip install -r requirements.txt \ No newline at end of file +# Run pip install -r application_data/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 36d1b6c..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: "3.8" - -services: - paccrypt: - build: . - container_name: paccrypt - ports: - - "5001:5000" - environment: - - PYTHONDONTWRITEBYTECODE=1 - - PYTHONUNBUFFERED=1 - - PRODUCTION=true - volumes: - - /mnt/stor4tb/uploads:/app/uploads - restart: unless-stopped - networks: - - shared_internal - -networks: - - shared_internal: - external: true \ No newline at end of file diff --git a/restart.bat b/restart.bat deleted file mode 100644 index d686c93..0000000 --- a/restart.bat +++ /dev/null @@ -1,7 +0,0 @@ - - @echo off - timeout /t 2 /nobreak - taskkill /F /PID 15428 - set PRODUCTION=true - start "" "python" "app.py" - \ No newline at end of file diff --git a/restart.sh b/restart.sh deleted file mode 100644 index 1f1de94..0000000 --- a/restart.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -sleep 2 - -# Save current process PID -PID=$1 - -# Gracefully stop the current server -kill "$PID" - -# Wait until it exits -while kill -0 "$PID" 2>/dev/null; do - sleep 0.5 -done - -# Restart with the same interpreter and script -export PRODUCTION=true -exec "$2" "$3" diff --git a/settings.json b/settings.json deleted file mode 100644 index 0642050..0000000 --- a/settings.json +++ /dev/null @@ -1 +0,0 @@ -{"upload_folder": "uploads", "max_file_age_days": 14, "max_file_size_bytes": 26843545600} \ No newline at end of file diff --git a/start_dev.bat b/start_dev.bat deleted file mode 100644 index 8214467..0000000 --- a/start_dev.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -echo Starting PacCrypt in DEVELOPMENT mode... -set PRODUCTION=false -python app.py -pause diff --git a/start_dev.sh b/start_dev.sh deleted file mode 100644 index 6fe5464..0000000 --- a/start_dev.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -echo "Starting PacCrypt in DEVELOPMENT mode..." -export PRODUCTION=false -python3 app.py diff --git a/start_prod.bat b/start_prod.bat deleted file mode 100644 index 2902d46..0000000 --- a/start_prod.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -echo Starting PacCrypt in PRODUCTION mode... -set PRODUCTION=true -python app.py -pause diff --git a/start_prod.sh b/start_prod.sh deleted file mode 100644 index 50b9bac..0000000 --- a/start_prod.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -echo "Starting PacCrypt in PRODUCTION mode..." -export PRODUCTION=true -python3 app.py \ No newline at end of file diff --git a/static/img/Sammons_Tyler.pdf b/static/img/Sammons_Tyler.pdf new file mode 100644 index 0000000..432c29d Binary files /dev/null and b/static/img/Sammons_Tyler.pdf differ diff --git a/static/img/sitemap.png b/static/img/sitemap.png index 095fc38..bda0fc6 100644 Binary files a/static/img/sitemap.png and b/static/img/sitemap.png differ