Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions start.bat
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
@echo off
setlocal
setlocal enabledelayedexpansion
set DIR=%~dp0
set CONFIG=%1
if "%CONFIG%"=="" set CONFIG=%DIR%config\c2pool_mainnet.yaml

echo === c2pool ===
:: Locate the packaged coin binary. release.yml packages it per-coin as
:: c2pool-<coin>.exe, so resolve by glob rather than a hard-coded name;
:: fall back to a plain c2pool.exe for source builds.
set BIN=
for %%f in ("%DIR%c2pool-*.exe") do set BIN=%%f
if "!BIN!"=="" if exist "%DIR%c2pool.exe" set BIN=%DIR%c2pool.exe
if "!BIN!"=="" (
echo ERROR: no c2pool binary found in %DIR%
exit /b 1
)
for %%f in ("!BIN!") do set BINNAME=%%~nxf

echo === !BINNAME! ===
echo Config: %CONFIG%
echo Web: http://0.0.0.0:8080
echo Explorer: http://0.0.0.0:9090

:: Start c2pool
start /B "" "%DIR%c2pool.exe" --config "%CONFIG%" --dashboard-dir "%DIR%web-static"
start /B "" "!BIN!" --config "%CONFIG%" --dashboard-dir "%DIR%web-static"

:: Wait for API
:wait_loop
Expand Down
18 changes: 14 additions & 4 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,38 @@ CONFIG="${1:-$DIR/config/c2pool_mainnet.yaml}"
EXPLORER_PORT=9090
WEB_PORT=8080

# Locate the packaged coin binary. release.yml packages it per-coin as
# c2pool-<coin> (c2pool-ltc, c2pool-btc, ...), so resolve by glob rather
# than a hard-coded name; fall back to a plain c2pool for source builds.
BIN=$(find "$DIR" -maxdepth 1 -type f -name "c2pool-*" -perm -u+x 2>/dev/null | head -1)
[ -z "$BIN" ] && [ -x "$DIR/c2pool" ] && BIN="$DIR/c2pool"
if [ -z "$BIN" ]; then
echo "ERROR: no c2pool binary found in $DIR" >&2
exit 1
fi

# Parse web_port from config if present
if [ -f "$CONFIG" ]; then
WP=$(grep -E "^web_port:" "$CONFIG" 2>/dev/null | awk '{print $2}')
WP=$(grep -E "^web_port:" "$CONFIG" 2>/dev/null | awk "{print \$2}")
[ -n "$WP" ] && WEB_PORT="$WP"
fi

echo "=== c2pool v0.1.1-alpha ==="
echo "=== $(basename "$BIN") ==="
echo "Config: $CONFIG"
echo "Web: http://0.0.0.0:${WEB_PORT}"
echo "Explorer: http://0.0.0.0:${EXPLORER_PORT}"
echo ""

# Start c2pool with bundled libs
export LD_LIBRARY_PATH="$DIR/lib:${LD_LIBRARY_PATH:-}"
"$DIR/c2pool" --config "$CONFIG" --dashboard-dir "$DIR/web-static" &
"$BIN" --config "$CONFIG" --dashboard-dir "$DIR/web-static" &
C2POOL_PID=$!

# Wait for the explorer API to be ready (callbacks wired after full init)
echo "Waiting for c2pool to initialize..."
for i in $(seq 1 120); do
RESP=$(curl -s "http://127.0.0.1:${WEB_PORT}/api/explorer/getblockchaininfo" 2>/dev/null || true)
if echo "$RESP" | grep -q '"blocks"'; then
if echo "$RESP" | grep -q "\"blocks\""; then
echo "c2pool explorer API ready."
break
fi
Expand Down
Loading