Просмотр исходного кода

explorer/site: Add help target and reorganize Makefile

- Add help target with organized documentation of available commands
- Rename 'stop-server' target to more concise 'stop'
- Fix Python executable path (use generic 'python' instead of hard-coded path)
- Reorganize sections for better logical grouping
- Generalized naming to explorer site
- Added console statements to show the testnet and mainnet log locations on startup to see server startup details
kalm 1 год назад
Родитель
Сommit
27d8618e84
1 измененных файлов с 39 добавлено и 17 удалено
  1. 39 17
      bin/explorer/site/Makefile

+ 39 - 17
bin/explorer/site/Makefile

@@ -1,7 +1,22 @@
 BIN := venv/bin/activate
-PYTHON := /opt/tools/python/bin/python3.12
+PYTHON := python
 
-all: $(BIN)
+LOG_HOME := $(shell echo ~/.local/share/darkfi/explorer_site)
+
+help:
+	@echo "Explorer Site Makefile Commands:"
+	@echo ""
+	@echo "Installation and cleanup:"
+	@echo "  make install       - Install Python dependencies in a virtual environment"
+	@echo "  make clean         - Remove the virtual environment and installed dependencies"
+	@echo ""
+	@echo "Server management:"
+	@echo "  make start-localnet - Start explorer site on localnet environment"
+	@echo "  make start-testnet  - Start explorer site on testnet environment"
+	@echo "  make start-mainnet  - Start explorer site on mainnet environment"
+	@echo "  make stop           - Stop running explorer site"
+
+install: $(BIN)
 
 # Create the virtual environment and install dependencies
 $(BIN): requirements.txt
@@ -11,39 +26,46 @@ $(BIN): requirements.txt
 	fi; \
 	. venv/bin/activate && pip install -r requirements.txt
 
+# Remove virtual environment
+clean:
+	@rm -rf venv
+	@echo "Cleaned the virtual environment!"
+
 # Start the Flask server for the specified network (localnet, testnet, mainnet)
-start-%: all
+start-%: install
 	@if [ "$*" != "localnet" ] && [ "$*" != "testnet" ] && [ "$*" != "mainnet" ]; then \
 		echo "Error: Unsupported environment '$*'. Supported values are 'localnet', 'testnet', and 'mainnet'."; \
 		exit 1; \
 	fi
 	@if [ -f flask.pid ]; then \
-		echo "Flask server is already running (PID=$$(cat flask.pid)). Stop it first before starting."; \
+		echo "Explorer site is already running (PID=$$(cat flask.pid)). Stop it first before starting."; \
 		exit 1; \
 	fi
 	@. venv/bin/activate && \
 		FLASK_ENV=$* python -m flask run & PID=$$!; \
 		echo $$PID > flask.pid; \
-		echo "Started flask server on $* network (PID=$$PID)"
+		echo "Started explorer site on $* network (PID=$$PID)"
+
+	@if [ "$*" = "testnet" ]; then \
+		echo "See site logfile $(LOG_HOME)/testnet/app.log for server startup details"; \
+	fi
 
-# Stop the Flask server if running
-stop-server:
+	@if [ "$*" = "mainnet" ]; then \
+		echo "See site logfile $(LOG_HOME)/mainnet/app.log for server startup details"; \
+	fi
+
+# Stop the explorer site if running
+stop:
 	@if [ -f flask.pid ]; then \
 		PID=$$(cat flask.pid); \
 		kill $$PID; \
 		rm -f flask.pid; \
-		echo "Stopped Flask server"; \
+		echo "Stopped explorer site"; \
 	else \
-		echo "Flask server is not running, nothing to stop."; \
+		if [ "$(suppress_not_running)" != "1" ]; then \
+			echo "Explorer site is not running, nothing to stop."; \
+		fi; \
 	fi
 
-# Install dependencies (alias for 'all')
-install: all
-
-# Remove virtual environment
-clean:
-	@rm -rf venv
-	@echo "Cleaned the virtual environment!"
-
 # Declare PHONY targets
 .PHONY: all start-% install clean stop-server