浏览代码

explorer: introduce single command explorer launch

This commit adds the ability to start an explorer environment with a single command. The new Makefile addition streamlines the process of working with the DarkFi explorer across various network configurations, catering to users with diverse needs.

The implementation automates startup and shutdown for explorer environments while managing dependencies efficiently, ensuring that missing components are automatically built. It also launches the explorer site (UI), verifying that all required dependencies are installed beforehand. The startup process is orchestrated so that `darkfid` initializes first, followed by `explorerd`, and the UI is launched after verifying that the explorer node is fully operational.

These improvements allow a diverse community of users to focus on what matters most to them without concern for environment setup, startup, or shutdown.

For usage details, run: `make help`

Key Features:
- Single-command to start/stop explorer environments for Darkfi localnet, testnet, or mainnet networks
- Automatic dependency management and node building
- Graceful shutdown with a single keyboard interrupt (Ctrl-C)
- Sequential startup to prevent race conditions
- Organized node logging for each network (localnet, testnet, mainnet)
- Enhanced `make help` help documentation
kalm 1 年之前
父节点
当前提交
d22d96d17d
共有 1 个文件被更改,包括 34 次插入0 次删除
  1. 34 0
      bin/explorer/Makefile

+ 34 - 0
bin/explorer/Makefile

@@ -0,0 +1,34 @@
+.POSIX:
+
+# Suppress all directory-related messages for cleaner output
+MAKEFLAGS += --no-print-directory
+
+help:
+	@echo "Explorer Makefile Commands:"
+	@echo ""
+	@echo "Network management:"
+	@echo "  make start-localnet - Start explorer environment on Darkfi localnet"
+	@echo "  make start-testnet  - Start explorer environment on Darkfi testnet"
+	@echo "  make start-mainnet  - Start explorer environment on Darkfi mainnet"
+	@echo "  make stop           - Stop running explorer environment"
+
+# Start a full explorer environment on Darkfi networks (localnet, testnet, mainnet)
+start-%:
+	@echo "Starting $* environment..."
+	@sh -c ' \
+		trap "echo Interrupt detected; make stop; exit 0" INT; \
+		$(MAKE) -C ./explorerd start-$*; \
+		$(MAKE) -C ./explorerd await-startup-$*; \
+		$(MAKE) -C ./site start-$*; \
+		echo "Started $* environment. Press Ctrl-C to stop."; \
+		while true; do sleep 1; done; \
+	'
+
+# Stop the running network
+stop:
+	@$(MAKE) -C ./explorerd stop || true; \
+	$(MAKE) -C ./site stop || true; \
+
+.PHONY: start-% check-minerd check-darkfid check-explorerd check-site stop
+
+