From 10eb7cba303c3ce4653a7590bdddf8879dfe53be Mon Sep 17 00:00:00 2001 From: JacobLef Date: Tue, 14 Oct 2025 14:00:57 -0400 Subject: [PATCH 01/32] Initial setup. --- scripts/boot.py | 0 scripts/start.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 scripts/boot.py create mode 100644 scripts/start.py diff --git a/scripts/boot.py b/scripts/boot.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/start.py b/scripts/start.py new file mode 100644 index 00000000..e69de29b From 54245409d7302343764190986d345ad954329259 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Tue, 14 Oct 2025 14:00:57 -0400 Subject: [PATCH 02/32] Initial setup. --- scripts/boot.py | 0 scripts/start.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 scripts/boot.py create mode 100644 scripts/start.py diff --git a/scripts/boot.py b/scripts/boot.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/start.py b/scripts/start.py new file mode 100644 index 00000000..e69de29b From 99cef98561bb0d88b473c5df271544597620d1d6 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 16 Oct 2025 22:22:37 -0400 Subject: [PATCH 03/32] Docker compose file is updated with MongoDB configuration. Dump and seed script files have been created. --- docker-compose.yml | 11 +++++++++++ scripts/dump.py | 0 scripts/seed.py | 0 3 files changed, 11 insertions(+) create mode 100644 scripts/dump.py create mode 100644 scripts/seed.py diff --git a/docker-compose.yml b/docker-compose.yml index fe30a4a3..46607fb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,5 +8,16 @@ services: command: redis-server --appendonly yes restart: unless-stopped + mongodb: + image: mongodb/mongodb-community-server:6.0-ubi8 + ports: + - "27017:27017" + environment: + - MONGO_INITDB_ROOT_USERNAME=devuser + - MONGO_INITDB_ROOT_PASSWORDdevpassword123= + volumes: + - mongodb_data:/data/db + volumes: redis_data: + mongodb_data: diff --git a/scripts/dump.py b/scripts/dump.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/seed.py b/scripts/seed.py new file mode 100644 index 00000000..e69de29b From f28d89fe219424eaf5b92317293d498a198a4a39 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 16:07:04 -0400 Subject: [PATCH 04/32] Boot file started. --- scripts/boot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/boot.py b/scripts/boot.py index e69de29b..e7dcde53 100644 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -0,0 +1,9 @@ +import subprocess + +def cleanup(): + try: + subprocess.run(["docker", "compose", "down"]) + except (Exception): + subprocess.run(["echo", "Error shutting down docker infrastructure!"]) + +subprocess.run(["echo", "Booting up redis and mongodb infrastructure..."]) From e9dfea90be36945fd768ea4c94e4eabf27b310ac Mon Sep 17 00:00:00 2001 From: JacobLef Date: Tue, 14 Oct 2025 14:00:57 -0400 Subject: [PATCH 05/32] Initial setup. --- scripts/boot.py | 0 scripts/start.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 scripts/boot.py create mode 100644 scripts/start.py diff --git a/scripts/boot.py b/scripts/boot.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/start.py b/scripts/start.py new file mode 100644 index 00000000..e69de29b From c02ac5477a7ee5b3c21e8cf9b1c9412c27024335 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 16 Oct 2025 22:22:37 -0400 Subject: [PATCH 06/32] Docker compose file is updated with MongoDB configuration. Dump and seed script files have been created. --- docker-compose.yml | 11 +++++++++++ scripts/dump.py | 0 scripts/seed.py | 0 3 files changed, 11 insertions(+) create mode 100644 scripts/dump.py create mode 100644 scripts/seed.py diff --git a/docker-compose.yml b/docker-compose.yml index fe30a4a3..46607fb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,5 +8,16 @@ services: command: redis-server --appendonly yes restart: unless-stopped + mongodb: + image: mongodb/mongodb-community-server:6.0-ubi8 + ports: + - "27017:27017" + environment: + - MONGO_INITDB_ROOT_USERNAME=devuser + - MONGO_INITDB_ROOT_PASSWORDdevpassword123= + volumes: + - mongodb_data:/data/db + volumes: redis_data: + mongodb_data: diff --git a/scripts/dump.py b/scripts/dump.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/seed.py b/scripts/seed.py new file mode 100644 index 00000000..e69de29b From a4b3f7dc4749378695bf4146205eec06a8015d68 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 16:07:04 -0400 Subject: [PATCH 07/32] Boot file started. --- scripts/boot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/boot.py b/scripts/boot.py index e69de29b..e7dcde53 100644 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -0,0 +1,9 @@ +import subprocess + +def cleanup(): + try: + subprocess.run(["docker", "compose", "down"]) + except (Exception): + subprocess.run(["echo", "Error shutting down docker infrastructure!"]) + +subprocess.run(["echo", "Booting up redis and mongodb infrastructure..."]) From 870056f70cff658412798b0f07f90321ec00cf95 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 23:01:49 -0400 Subject: [PATCH 08/32] Initial attempt at boot and start scripts completed. General structure laid out for cleanup, infra, and program/application start is done. --- package.json | 2 +- scripts/boot.py | 29 +++++++++++++++++++++++++---- scripts/start.py | 10 ++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) mode change 100644 => 100755 scripts/boot.py mode change 100644 => 100755 scripts/start.py diff --git a/package.json b/package.json index cd97897e..4e2d4a49 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "prettier:fix": "prettier . --write", "format": "pnpm prettier:fix && pnpm lint:fix", "prepare": "husky install", - "dev": "pnpm --stream -r dev", + "dev": "python3 ./scripts/boot.py", "dev:infra": "docker-compose up -d redis", "dev:infra:stop": "docker-compose down redis" }, diff --git a/scripts/boot.py b/scripts/boot.py old mode 100644 new mode 100755 index e7dcde53..228cb240 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,9 +1,30 @@ import subprocess +import signal +import sys def cleanup(): + print("Shutting down docker infrastructure...") try: - subprocess.run(["docker", "compose", "down"]) - except (Exception): - subprocess.run(["echo", "Error shutting down docker infrastructure!"]) + subprocess.run(["docker", "compose", "down"], check=True) + print("Docker infrastructure stopped successfully!") + except subprocess.CalledProcessError: + print("Error shutting down docker infrastructure!") -subprocess.run(["echo", "Booting up redis and mongodb infrastructure..."]) +def start_infrastructure(): + print("Booting up redis and mongodb...") + try: + subprocess.run(["docker", "compose", "up", "-d"], check=True) + except subprocess.CalledProcessError: + print("Error starting docker infrastructure!") + exit(1) + +def signal_handler(sig, frame): + cleanup() + sys.exit(0) + +signal.signal(signal.SIGINT, signal_handler) +start_infrastructure() +try: + subprocess.run(["python3", "./start.py"], check=True) +finally: + cleanup() \ No newline at end of file diff --git a/scripts/start.py b/scripts/start.py old mode 100644 new mode 100755 index e69de29b..9fb57e29 --- a/scripts/start.py +++ b/scripts/start.py @@ -0,0 +1,10 @@ +import subprocess + +def start(): + try: + subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) + except subprocess.CalledProcessError: + print("Error starting application!") + exit(1) + +start() \ No newline at end of file From 78922fa73c0c9621a58f93b94d89d532383d3802 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 23:56:06 -0400 Subject: [PATCH 09/32] Boot script is completed. Automatically launches and configures containersa and redis servers. --- scripts/boot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index 228cb240..bfa89148 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -16,7 +16,7 @@ def start_infrastructure(): subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - exit(1) + sys.exit(1) def signal_handler(sig, frame): cleanup() @@ -25,6 +25,6 @@ def signal_handler(sig, frame): signal.signal(signal.SIGINT, signal_handler) start_infrastructure() try: - subprocess.run(["python3", "./start.py"], check=True) + subprocess.run(["python3", "scripts/start.py"], check=True) finally: cleanup() \ No newline at end of file From 850a1e7fae9389d516149bccdb967d976696caef Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 23:59:15 -0400 Subject: [PATCH 10/32] Updated pacakge.json scripts and README file to relfect script changes. --- README.md | 16 ++-------------- package.json | 4 +--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7876f210..0a257437 100644 --- a/README.md +++ b/README.md @@ -10,26 +10,14 @@ pnpm install ``` -### Boot the Infrastructure (Redis Server) - -```bash -pnpm run dev:infra -``` - ### Run the Program ```bash pnpm run dev ``` -### Cleanup Docker Infrastructure - -```bash -pnpm run dev:infra:stop -``` - -### To see if you have a Docker container currently running +### To see if you have any containers currently running ```bash -docker ps +docker compose ps ``` diff --git a/package.json b/package.json index 4e2d4a49..40615e5e 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ "prettier:fix": "prettier . --write", "format": "pnpm prettier:fix && pnpm lint:fix", "prepare": "husky install", - "dev": "python3 ./scripts/boot.py", - "dev:infra": "docker-compose up -d redis", - "dev:infra:stop": "docker-compose down redis" + "dev": "python3 ./scripts/boot.py" }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", From be26203c760276b342319d0482788560b5c20119 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 10:50:53 -0400 Subject: [PATCH 11/32] Updated boot script to correctly shut down everything without having error messages. --- scripts/boot.py | 13 +++++++++---- scripts/start.py | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index bfa89148..ef12810b 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -16,15 +16,20 @@ def start_infrastructure(): subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - sys.exit(1) + cleanup() def signal_handler(sig, frame): cleanup() sys.exit(0) signal.signal(signal.SIGINT, signal_handler) + start_infrastructure() try: - subprocess.run(["python3", "scripts/start.py"], check=True) -finally: - cleanup() \ No newline at end of file + subprocess.run( + ["python3", "scripts/start.py"], + check=True, + stderr=subprocess.PIPE + ) +except (KeyboardInterrupt, subprocess.CalledProcessError): + pass \ No newline at end of file diff --git a/scripts/start.py b/scripts/start.py index 9fb57e29..faa3e5cb 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -1,10 +1,10 @@ import subprocess -def start(): +def init(): try: subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) except subprocess.CalledProcessError: print("Error starting application!") exit(1) -start() \ No newline at end of file +init() \ No newline at end of file From b33739eb4f0a2c0e87f8c3081e4278b4ff91fb23 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 10:53:26 -0400 Subject: [PATCH 12/32] Updated boot script to shut down containers only once. Removed SIGINT recogniition for shutdown and moved shutdown criteria to be Keyboard interruption or a process error. --- scripts/boot.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index ef12810b..976c62fe 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,6 +1,4 @@ import subprocess -import signal -import sys def cleanup(): print("Shutting down docker infrastructure...") @@ -16,20 +14,12 @@ def start_infrastructure(): subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - cleanup() - -def signal_handler(sig, frame): - cleanup() - sys.exit(0) - -signal.signal(signal.SIGINT, signal_handler) + exit(1) start_infrastructure() try: - subprocess.run( - ["python3", "scripts/start.py"], - check=True, - stderr=subprocess.PIPE - ) + subprocess.run(["python3", "scripts/start.py"], check=True) except (KeyboardInterrupt, subprocess.CalledProcessError): - pass \ No newline at end of file + pass +finally: + cleanup() \ No newline at end of file From d43102bee56b36745842d3a67b7843b880f3d099 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 10:59:06 -0400 Subject: [PATCH 13/32] Updated boot script with docstrings. --- scripts/boot.py | 11 +++++++++-- scripts/start.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index 976c62fe..2c43dace 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,6 +1,10 @@ import subprocess -def cleanup(): +def cleanup() -> None: + """ + Shuts down any docker infrastructure that is currently running. Does not propagate any errors, only error messages if there are issues shutting down the infrastructure. + """ + print("Shutting down docker infrastructure...") try: subprocess.run(["docker", "compose", "down"], check=True) @@ -8,7 +12,10 @@ def cleanup(): except subprocess.CalledProcessError: print("Error shutting down docker infrastructure!") -def start_infrastructure(): +def start_infrastructure() -> None: + """ + Starts the Docker infrastructure such that both redis and mongodb containers are launched. Does not propagate any errors, only prints an error message and than exits with an error code. + """ print("Booting up redis and mongodb...") try: subprocess.run(["docker", "compose", "up", "-d"], check=True) diff --git a/scripts/start.py b/scripts/start.py index faa3e5cb..f79bb06c 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -1,6 +1,6 @@ import subprocess -def init(): +def init() -> None: try: subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) except subprocess.CalledProcessError: From c25b61af65fe2ff5ffc9b3c6a87c96897b0a9359 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 19:30:32 -0400 Subject: [PATCH 14/32] Started dump file. --- scripts/dump.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/dump.py b/scripts/dump.py index e69de29b..f5486f10 100644 --- a/scripts/dump.py +++ b/scripts/dump.py @@ -0,0 +1,14 @@ +import os +import subprocess + +def load_env(filepath='../packages/api/.env'): + with open(filepath) as f: + for line in f: + line = line.strip() + if line and not line.startswith('#') and '=' in line: + key, value = line.split('=', 1) + os.environ[key.strip()] = value.strip() + +load_env() +mongo_url = os.getenv('MONGO_URL') + From 3653b7e4ccb935129ef1dcece512a0b3e1899b8f Mon Sep 17 00:00:00 2001 From: JacobLef Date: Tue, 14 Oct 2025 14:00:57 -0400 Subject: [PATCH 15/32] Initial setup. --- scripts/boot.py | 0 scripts/start.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 scripts/boot.py create mode 100644 scripts/start.py diff --git a/scripts/boot.py b/scripts/boot.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/start.py b/scripts/start.py new file mode 100644 index 00000000..e69de29b From 7f696c0db8114542f35fd263b8d2b969ec01ebdb Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 16 Oct 2025 22:22:37 -0400 Subject: [PATCH 16/32] Docker compose file is updated with MongoDB configuration. Dump and seed script files have been created. --- docker-compose.yml | 11 +++++++++++ scripts/dump.py | 0 scripts/seed.py | 0 3 files changed, 11 insertions(+) create mode 100644 scripts/dump.py create mode 100644 scripts/seed.py diff --git a/docker-compose.yml b/docker-compose.yml index fe30a4a3..46607fb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,5 +8,16 @@ services: command: redis-server --appendonly yes restart: unless-stopped + mongodb: + image: mongodb/mongodb-community-server:6.0-ubi8 + ports: + - "27017:27017" + environment: + - MONGO_INITDB_ROOT_USERNAME=devuser + - MONGO_INITDB_ROOT_PASSWORDdevpassword123= + volumes: + - mongodb_data:/data/db + volumes: redis_data: + mongodb_data: diff --git a/scripts/dump.py b/scripts/dump.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/seed.py b/scripts/seed.py new file mode 100644 index 00000000..e69de29b From a43315a65d2d4d2e75c37e77a0e5aaf19f84f599 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 16:07:04 -0400 Subject: [PATCH 17/32] Boot file started. --- scripts/boot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/boot.py b/scripts/boot.py index e69de29b..e7dcde53 100644 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -0,0 +1,9 @@ +import subprocess + +def cleanup(): + try: + subprocess.run(["docker", "compose", "down"]) + except (Exception): + subprocess.run(["echo", "Error shutting down docker infrastructure!"]) + +subprocess.run(["echo", "Booting up redis and mongodb infrastructure..."]) From f60644e3b1275af1c300b553e6fee4f51f80fce3 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 23:01:49 -0400 Subject: [PATCH 18/32] Initial attempt at boot and start scripts completed. General structure laid out for cleanup, infra, and program/application start is done. --- package.json | 2 +- scripts/boot.py | 29 +++++++++++++++++++++++++---- scripts/start.py | 10 ++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) mode change 100644 => 100755 scripts/boot.py mode change 100644 => 100755 scripts/start.py diff --git a/package.json b/package.json index cd97897e..4e2d4a49 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "prettier:fix": "prettier . --write", "format": "pnpm prettier:fix && pnpm lint:fix", "prepare": "husky install", - "dev": "pnpm --stream -r dev", + "dev": "python3 ./scripts/boot.py", "dev:infra": "docker-compose up -d redis", "dev:infra:stop": "docker-compose down redis" }, diff --git a/scripts/boot.py b/scripts/boot.py old mode 100644 new mode 100755 index e7dcde53..228cb240 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,9 +1,30 @@ import subprocess +import signal +import sys def cleanup(): + print("Shutting down docker infrastructure...") try: - subprocess.run(["docker", "compose", "down"]) - except (Exception): - subprocess.run(["echo", "Error shutting down docker infrastructure!"]) + subprocess.run(["docker", "compose", "down"], check=True) + print("Docker infrastructure stopped successfully!") + except subprocess.CalledProcessError: + print("Error shutting down docker infrastructure!") -subprocess.run(["echo", "Booting up redis and mongodb infrastructure..."]) +def start_infrastructure(): + print("Booting up redis and mongodb...") + try: + subprocess.run(["docker", "compose", "up", "-d"], check=True) + except subprocess.CalledProcessError: + print("Error starting docker infrastructure!") + exit(1) + +def signal_handler(sig, frame): + cleanup() + sys.exit(0) + +signal.signal(signal.SIGINT, signal_handler) +start_infrastructure() +try: + subprocess.run(["python3", "./start.py"], check=True) +finally: + cleanup() \ No newline at end of file diff --git a/scripts/start.py b/scripts/start.py old mode 100644 new mode 100755 index e69de29b..9fb57e29 --- a/scripts/start.py +++ b/scripts/start.py @@ -0,0 +1,10 @@ +import subprocess + +def start(): + try: + subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) + except subprocess.CalledProcessError: + print("Error starting application!") + exit(1) + +start() \ No newline at end of file From 5c0840f9640916ce83d46f2ac3c704c1b28ff8d3 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 23:56:06 -0400 Subject: [PATCH 19/32] Boot script is completed. Automatically launches and configures containersa and redis servers. --- scripts/boot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index 228cb240..bfa89148 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -16,7 +16,7 @@ def start_infrastructure(): subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - exit(1) + sys.exit(1) def signal_handler(sig, frame): cleanup() @@ -25,6 +25,6 @@ def signal_handler(sig, frame): signal.signal(signal.SIGINT, signal_handler) start_infrastructure() try: - subprocess.run(["python3", "./start.py"], check=True) + subprocess.run(["python3", "scripts/start.py"], check=True) finally: cleanup() \ No newline at end of file From 0a9b4211e4d29620d3079c23b426e6329b9ca9e4 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Fri, 17 Oct 2025 23:59:15 -0400 Subject: [PATCH 20/32] Updated pacakge.json scripts and README file to relfect script changes. --- README.md | 16 ++-------------- package.json | 4 +--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7876f210..0a257437 100644 --- a/README.md +++ b/README.md @@ -10,26 +10,14 @@ pnpm install ``` -### Boot the Infrastructure (Redis Server) - -```bash -pnpm run dev:infra -``` - ### Run the Program ```bash pnpm run dev ``` -### Cleanup Docker Infrastructure - -```bash -pnpm run dev:infra:stop -``` - -### To see if you have a Docker container currently running +### To see if you have any containers currently running ```bash -docker ps +docker compose ps ``` diff --git a/package.json b/package.json index 4e2d4a49..40615e5e 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ "prettier:fix": "prettier . --write", "format": "pnpm prettier:fix && pnpm lint:fix", "prepare": "husky install", - "dev": "python3 ./scripts/boot.py", - "dev:infra": "docker-compose up -d redis", - "dev:infra:stop": "docker-compose down redis" + "dev": "python3 ./scripts/boot.py" }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", From 1275a676b2eecbf07ad8373395221e4c48a8b004 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 10:50:53 -0400 Subject: [PATCH 21/32] Updated boot script to correctly shut down everything without having error messages. --- scripts/boot.py | 13 +++++++++---- scripts/start.py | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index bfa89148..ef12810b 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -16,15 +16,20 @@ def start_infrastructure(): subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - sys.exit(1) + cleanup() def signal_handler(sig, frame): cleanup() sys.exit(0) signal.signal(signal.SIGINT, signal_handler) + start_infrastructure() try: - subprocess.run(["python3", "scripts/start.py"], check=True) -finally: - cleanup() \ No newline at end of file + subprocess.run( + ["python3", "scripts/start.py"], + check=True, + stderr=subprocess.PIPE + ) +except (KeyboardInterrupt, subprocess.CalledProcessError): + pass \ No newline at end of file diff --git a/scripts/start.py b/scripts/start.py index 9fb57e29..faa3e5cb 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -1,10 +1,10 @@ import subprocess -def start(): +def init(): try: subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) except subprocess.CalledProcessError: print("Error starting application!") exit(1) -start() \ No newline at end of file +init() \ No newline at end of file From 4087c5873d621f286211719642f0a17b4fa48c2f Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 10:53:26 -0400 Subject: [PATCH 22/32] Updated boot script to shut down containers only once. Removed SIGINT recogniition for shutdown and moved shutdown criteria to be Keyboard interruption or a process error. --- scripts/boot.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index ef12810b..976c62fe 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,6 +1,4 @@ import subprocess -import signal -import sys def cleanup(): print("Shutting down docker infrastructure...") @@ -16,20 +14,12 @@ def start_infrastructure(): subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - cleanup() - -def signal_handler(sig, frame): - cleanup() - sys.exit(0) - -signal.signal(signal.SIGINT, signal_handler) + exit(1) start_infrastructure() try: - subprocess.run( - ["python3", "scripts/start.py"], - check=True, - stderr=subprocess.PIPE - ) + subprocess.run(["python3", "scripts/start.py"], check=True) except (KeyboardInterrupt, subprocess.CalledProcessError): - pass \ No newline at end of file + pass +finally: + cleanup() \ No newline at end of file From 358aa6672fe350fb6a72eef889ddae57d90fd18b Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 10:59:06 -0400 Subject: [PATCH 23/32] Updated boot script with docstrings. --- scripts/boot.py | 11 +++++++++-- scripts/start.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index 976c62fe..2c43dace 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,6 +1,10 @@ import subprocess -def cleanup(): +def cleanup() -> None: + """ + Shuts down any docker infrastructure that is currently running. Does not propagate any errors, only error messages if there are issues shutting down the infrastructure. + """ + print("Shutting down docker infrastructure...") try: subprocess.run(["docker", "compose", "down"], check=True) @@ -8,7 +12,10 @@ def cleanup(): except subprocess.CalledProcessError: print("Error shutting down docker infrastructure!") -def start_infrastructure(): +def start_infrastructure() -> None: + """ + Starts the Docker infrastructure such that both redis and mongodb containers are launched. Does not propagate any errors, only prints an error message and than exits with an error code. + """ print("Booting up redis and mongodb...") try: subprocess.run(["docker", "compose", "up", "-d"], check=True) diff --git a/scripts/start.py b/scripts/start.py index faa3e5cb..f79bb06c 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -1,6 +1,6 @@ import subprocess -def init(): +def init() -> None: try: subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) except subprocess.CalledProcessError: From 36a7c0c48e75bdaf9be17197366edc2fd9b52599 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 19:30:32 -0400 Subject: [PATCH 24/32] Started dump file. --- scripts/dump.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/dump.py b/scripts/dump.py index e69de29b..f5486f10 100644 --- a/scripts/dump.py +++ b/scripts/dump.py @@ -0,0 +1,14 @@ +import os +import subprocess + +def load_env(filepath='../packages/api/.env'): + with open(filepath) as f: + for line in f: + line = line.strip() + if line and not line.startswith('#') and '=' in line: + key, value = line.split('=', 1) + os.environ[key.strip()] = value.strip() + +load_env() +mongo_url = os.getenv('MONGO_URL') + From 9856587401a5b9ee620f5808f77ae4db69a198b9 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sat, 18 Oct 2025 20:36:46 -0400 Subject: [PATCH 25/32] Changed boot.py to rely on whatever your OS finds to be the python executable. --- scripts/boot.py | 3 ++- scripts/dump.py | 14 -------------- scripts/seed.py | 0 3 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 scripts/dump.py delete mode 100644 scripts/seed.py diff --git a/scripts/boot.py b/scripts/boot.py index 2c43dace..be033e61 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,4 +1,5 @@ import subprocess +import sys def cleanup() -> None: """ @@ -25,7 +26,7 @@ def start_infrastructure() -> None: start_infrastructure() try: - subprocess.run(["python3", "scripts/start.py"], check=True) + subprocess.run([sys.executable, "scripts/start.py"], check=True) except (KeyboardInterrupt, subprocess.CalledProcessError): pass finally: diff --git a/scripts/dump.py b/scripts/dump.py deleted file mode 100644 index f5486f10..00000000 --- a/scripts/dump.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import subprocess - -def load_env(filepath='../packages/api/.env'): - with open(filepath) as f: - for line in f: - line = line.strip() - if line and not line.startswith('#') and '=' in line: - key, value = line.split('=', 1) - os.environ[key.strip()] = value.strip() - -load_env() -mongo_url = os.getenv('MONGO_URL') - diff --git a/scripts/seed.py b/scripts/seed.py deleted file mode 100644 index e69de29b..00000000 From fa073ed93fb85d6df228e68334b82ae21646bf9b Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 23 Oct 2025 18:56:40 -0400 Subject: [PATCH 26/32] Updated scripts to be wrapped in node script. --- scripts/boot.py | 1 + scripts/wrapper.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 scripts/wrapper.js diff --git a/scripts/boot.py b/scripts/boot.py index be033e61..87ec8e9c 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -17,6 +17,7 @@ def start_infrastructure() -> None: """ Starts the Docker infrastructure such that both redis and mongodb containers are launched. Does not propagate any errors, only prints an error message and than exits with an error code. """ + print("Booting up redis and mongodb...") try: subprocess.run(["docker", "compose", "up", "-d"], check=True) diff --git a/scripts/wrapper.js b/scripts/wrapper.js new file mode 100755 index 00000000..45bd8dfc --- /dev/null +++ b/scripts/wrapper.js @@ -0,0 +1,35 @@ +#!/usr/bin/env node + +import { spawn } from "child_process"; +import { platform } from "process"; + +const pythonCmd = platform === "win32" ? "python" : "python3"; +const scriptPath = process.argv[2]; + +if (!scriptPath) { + console.error("Usage: node run-python.js "); + process.exit(1); +} + +console.log(`Running ${scriptPath} with ${pythonCmd}...`); + +const pythonProcess = spawn(pythonCmd, [scriptPath], { + stdio: "inherit", +}); + +pythonProcess.on("error", (error) => { + console.error(`Failed to start Python: ${error.message}`); + process.exit(1); +}); + +pythonProcess.on("close", (code) => { + process.exit(code || 0); +}); + +process.on("SIGINT", () => { + pythonProcess.kill("SIGINT"); +}); + +process.on("SIGTERM", () => { + pythonProcess.kill("SIGTERM"); +}); From 46a8db5d42306538fd03f610c4bd029db60c58c3 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 23 Oct 2025 18:56:59 -0400 Subject: [PATCH 27/32] Updated pnpm scripts. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 40615e5e..0c97886e 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "husky": "^8.0.0", "typescript": "^5.0.2" }, + "type": "module", "scripts": { "lint": "eslint . --ext .ts,.vue", "lint:fix": "eslint . --fix --ext .ts,.vue", @@ -23,7 +24,7 @@ "prettier:fix": "prettier . --write", "format": "pnpm prettier:fix && pnpm lint:fix", "prepare": "husky install", - "dev": "python3 ./scripts/boot.py" + "dev": "node ./scripts/wrapper.js ./scripts/boot.py" }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", From f869c9750c0bdf5ca1b07d9dfa187c37f5c213c8 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 23 Oct 2025 20:35:11 -0400 Subject: [PATCH 28/32] Updated start.py to not display error messages when shutting down the program. --- scripts/boot.py | 4 +++- scripts/start.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index 87ec8e9c..b0de95af 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,5 +1,6 @@ import subprocess import sys +from time import sleep def cleanup() -> None: """ @@ -12,6 +13,7 @@ def cleanup() -> None: print("Docker infrastructure stopped successfully!") except subprocess.CalledProcessError: print("Error shutting down docker infrastructure!") + raise subprocess.CalledProcessError() def start_infrastructure() -> None: """ @@ -23,7 +25,7 @@ def start_infrastructure() -> None: subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - exit(1) + raise subprocess.CalledProcessError() start_infrastructure() try: diff --git a/scripts/start.py b/scripts/start.py index f79bb06c..379d8414 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -2,9 +2,8 @@ def init() -> None: try: - subprocess.run(["pnpm", "--stream", "-r", "dev"], check=True) + subprocess.run(["pnpm", "--stream", "-r", "dev"]) except subprocess.CalledProcessError: print("Error starting application!") - exit(1) init() \ No newline at end of file From 72862f834dfc6b51bc5231bdc3bbcb4728995f2e Mon Sep 17 00:00:00 2001 From: JacobLef Date: Thu, 23 Oct 2025 20:38:10 -0400 Subject: [PATCH 29/32] Removed unused imports. --- scripts/boot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/boot.py b/scripts/boot.py index b0de95af..bdabcd83 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -1,6 +1,5 @@ import subprocess import sys -from time import sleep def cleanup() -> None: """ From c2ed0355f34c5af3b1c6f30b9f18abbabb0a1ca8 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sun, 26 Oct 2025 14:49:40 -0400 Subject: [PATCH 30/32] Attempt to fix Windows compatability with SIBREAK. --- scripts/wrapper.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/wrapper.js b/scripts/wrapper.js index 45bd8dfc..480408ab 100755 --- a/scripts/wrapper.js +++ b/scripts/wrapper.js @@ -33,3 +33,7 @@ process.on("SIGINT", () => { process.on("SIGTERM", () => { pythonProcess.kill("SIGTERM"); }); + +process.on("SIGBREAK", () => { + pythonProcess.kill("SIGBREAK"); +}); From c661c5d23f1dd65617d818bbc15a8fb190705e94 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sun, 26 Oct 2025 15:39:13 -0400 Subject: [PATCH 31/32] Updated wrapper to find the absolute path of your OS's python executable and execute the boot script with that. --- scripts/boot.py | 2 -- scripts/wrapper.js | 69 +++++++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index bdabcd83..f4897053 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -12,7 +12,6 @@ def cleanup() -> None: print("Docker infrastructure stopped successfully!") except subprocess.CalledProcessError: print("Error shutting down docker infrastructure!") - raise subprocess.CalledProcessError() def start_infrastructure() -> None: """ @@ -24,7 +23,6 @@ def start_infrastructure() -> None: subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") - raise subprocess.CalledProcessError() start_infrastructure() try: diff --git a/scripts/wrapper.js b/scripts/wrapper.js index 480408ab..9e00695e 100755 --- a/scripts/wrapper.js +++ b/scripts/wrapper.js @@ -1,39 +1,44 @@ #!/usr/bin/env node import { spawn } from "child_process"; -import { platform } from "process"; +import { platform } from "os"; -const pythonCmd = platform === "win32" ? "python" : "python3"; -const scriptPath = process.argv[2]; - -if (!scriptPath) { - console.error("Usage: node run-python.js "); - process.exit(1); +function findPythonExecutable() { + return platform() === "win32" ? "python" : "python3"; } -console.log(`Running ${scriptPath} with ${pythonCmd}...`); - -const pythonProcess = spawn(pythonCmd, [scriptPath], { - stdio: "inherit", -}); - -pythonProcess.on("error", (error) => { - console.error(`Failed to start Python: ${error.message}`); - process.exit(1); -}); - -pythonProcess.on("close", (code) => { - process.exit(code || 0); -}); - -process.on("SIGINT", () => { - pythonProcess.kill("SIGINT"); -}); - -process.on("SIGTERM", () => { - pythonProcess.kill("SIGTERM"); -}); +function startApplication() { + const pythonCmd = findPythonExecutable(); + console.log(`Starting application with ${pythonCmd}...`); + const child = spawn(pythonCmd, ["./scripts/boot.py"], { + stdio: "inherit", + shell: false, + }); + + // Forward signals to child process + const signals = ["SIGINT", "SIGTERM", "SIGHUP"]; + signals.forEach((signal) => { + process.on(signal, () => { + if (child.killed) return; + child.kill(signal); + }); + }); + + // Handle child process exit + child.on("exit", (code, signal) => { + if (signal) { + console.log(`\nProcess terminated by signal: ${signal}`); + process.exit(1); + } else { + process.exit(code || 0); + } + }); + + // Handle errors (e.g., python not found) + child.on("error", (err) => { + console.error(`Failed to start process: ${err.message}`); + process.exit(1); + }); +} -process.on("SIGBREAK", () => { - pythonProcess.kill("SIGBREAK"); -}); +startApplication(); From 21e4f763b8f7cdaa731894a065f3a7ff7313a0d5 Mon Sep 17 00:00:00 2001 From: JacobLef Date: Sun, 26 Oct 2025 16:39:16 -0400 Subject: [PATCH 32/32] Commits to attempt to fix. Doesn't work rn. --- scripts/boot.py | 2 ++ scripts/wrapper.js | 65 ++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/scripts/boot.py b/scripts/boot.py index f4897053..bdabcd83 100755 --- a/scripts/boot.py +++ b/scripts/boot.py @@ -12,6 +12,7 @@ def cleanup() -> None: print("Docker infrastructure stopped successfully!") except subprocess.CalledProcessError: print("Error shutting down docker infrastructure!") + raise subprocess.CalledProcessError() def start_infrastructure() -> None: """ @@ -23,6 +24,7 @@ def start_infrastructure() -> None: subprocess.run(["docker", "compose", "up", "-d"], check=True) except subprocess.CalledProcessError: print("Error starting docker infrastructure!") + raise subprocess.CalledProcessError() start_infrastructure() try: diff --git a/scripts/wrapper.js b/scripts/wrapper.js index 9e00695e..45bd8dfc 100755 --- a/scripts/wrapper.js +++ b/scripts/wrapper.js @@ -1,44 +1,35 @@ #!/usr/bin/env node import { spawn } from "child_process"; -import { platform } from "os"; +import { platform } from "process"; -function findPythonExecutable() { - return platform() === "win32" ? "python" : "python3"; -} +const pythonCmd = platform === "win32" ? "python" : "python3"; +const scriptPath = process.argv[2]; -function startApplication() { - const pythonCmd = findPythonExecutable(); - console.log(`Starting application with ${pythonCmd}...`); - const child = spawn(pythonCmd, ["./scripts/boot.py"], { - stdio: "inherit", - shell: false, - }); - - // Forward signals to child process - const signals = ["SIGINT", "SIGTERM", "SIGHUP"]; - signals.forEach((signal) => { - process.on(signal, () => { - if (child.killed) return; - child.kill(signal); - }); - }); - - // Handle child process exit - child.on("exit", (code, signal) => { - if (signal) { - console.log(`\nProcess terminated by signal: ${signal}`); - process.exit(1); - } else { - process.exit(code || 0); - } - }); - - // Handle errors (e.g., python not found) - child.on("error", (err) => { - console.error(`Failed to start process: ${err.message}`); - process.exit(1); - }); +if (!scriptPath) { + console.error("Usage: node run-python.js "); + process.exit(1); } -startApplication(); +console.log(`Running ${scriptPath} with ${pythonCmd}...`); + +const pythonProcess = spawn(pythonCmd, [scriptPath], { + stdio: "inherit", +}); + +pythonProcess.on("error", (error) => { + console.error(`Failed to start Python: ${error.message}`); + process.exit(1); +}); + +pythonProcess.on("close", (code) => { + process.exit(code || 0); +}); + +process.on("SIGINT", () => { + pythonProcess.kill("SIGINT"); +}); + +process.on("SIGTERM", () => { + pythonProcess.kill("SIGTERM"); +});