Harden miner wrapper: kill old processes, force API flags
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Wrapper script to start cgminer with correct flags based on selected mode
|
||||
|
||||
# Ensure we are in the script directory
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
MODE_FILE="mining_mode.conf"
|
||||
CONF_FILE="cgminer.conf"
|
||||
LOG_FILE="cgminer.log"
|
||||
|
||||
# Kill any existing instances that might block the port/device
|
||||
killall -9 cgminer 2>/dev/null
|
||||
sleep 1
|
||||
|
||||
# Default mode
|
||||
MODE="sha256"
|
||||
|
||||
@@ -17,20 +24,12 @@ FLAGS=""
|
||||
if [ "$MODE" == "scrypt" ]; then
|
||||
FLAGS="--scrypt"
|
||||
elif [ "$MODE" == "dual" ]; then
|
||||
# Dual mode usually implies scrypt flag + gridseed options, but purely depends on cgminer version behavior.
|
||||
# Often dual mode is default if scrypt is enabled?
|
||||
# Actually for gridseed:
|
||||
# SHA256 only: no --scrypt
|
||||
# Scrypt only: --scrypt --gridseed-options=scrypt
|
||||
# Dual: --scrypt --gridseed-options=... (default)
|
||||
# Let's assume:
|
||||
# SHA256: (no scrypt flag)
|
||||
# Scrypt: --scrypt
|
||||
FLAGS="--scrypt"
|
||||
fi
|
||||
|
||||
echo "Starting miner in mode: $MODE with flags: $FLAGS" > "$LOG_FILE"
|
||||
echo "[$(date)] Starting miner in mode: $MODE with flags: $FLAGS" >> "$LOG_FILE"
|
||||
|
||||
# Execute cgminer
|
||||
# Note: we use exec to replace the shell process
|
||||
exec /usr/local/bin/cgminer $FLAGS --gridseed-options freq=850 -c "$CONF_FILE" >> "$LOG_FILE" 2>&1
|
||||
# Forced API listening via command line args to ensure it's active
|
||||
# Added --api-allow W:127.0.0.1 explicitly just in case config is ignored
|
||||
exec /usr/local/bin/cgminer $FLAGS --gridseed-options freq=850 --api-listen --api-allow W:127.0.0.1 -c "$CONF_FILE" >> "$LOG_FILE" 2>&1
|
||||
|
||||
Reference in New Issue
Block a user