forked from sammy007/open-ethereum-pool
-
Notifications
You must be signed in to change notification settings - Fork 6
Pool Setup
aerth edited this page Feb 11, 2025
·
3 revisions
adduser --system aqua
adduser --system pool
open up only 21303 tcp/udp firewall
(this unit file has unlocked account listening on 127.0.0.1:8543 only for automatic pool payout setups)
You must change: <your-pool-coinbase>
to 0x1234...5678
Also: change '/dev/null' to some file with account password in it
[Unit]
Description=Aquachain Server (POOL)
[Service]
Type=simple
User=aqua
KillSignal=SIGINT
TimeoutStopSec=90s
Slice=aquachain.slice
WorkingDirectory=/home/aqua
ExecStart=/usr/local/bin/aquachain -aquabase <your-pool-coinbase> -rpc --unlock 0 --password '/dev/null' daemon
Restart=on-failure
StandardOutput=append:/var/log/aqua.log
StandardError=append:/var/log/aqua.log
[Install]
WantedBy=multi-user.target
[Unit]
Description=Aquachain Pool (Proxy)
Requires=redis.service
Requires=aquachain.service
[Service]
Type=simple
User=pool
KillSignal=SIGINT
TimeoutStopSec=90s
Slice=aquachain.slice
WorkingDirectory=/home/pool
ExecStart=/home/pool/bin/aquapool pool.json
Restart=on-failure
StandardOutput=append:/var/log/aquapool.log
StandardError=append:/var/log/aquapool.log
[Install]
WantedBy=default.target
listens on 80 tcp, 443 tcp/udp
(needed only to expose /api endpoint to view stats)
{
log {
format json
output stderr
}
}
:80 {
respond 403
}
# pool stats only (/ redirects to explorer page)
# change the domain name for auto-ssl
https://mypool.example.org {
reverse_proxy /api/* http://127.0.0.1:8080 {
header_up * Content-Type application/json
header_down Access-Control-Allow-Origin *
}
# redirect to explorer's pool out
@denied not path /api/*
redir @denied "https://aquachain.github.io/explorer/#/pool" 302
}
something like
10 * * * * /usr/local/sbin/backup_redis.bash -cron
contents of /usr/local/sbin/backup_redis.bash:
#!/bin/bash
# from https://github.com/aquachain/open-aquachain-pool/wiki/
set -e
if [ "$1" == "-cron" ]; then
RANDOM_SLEEP=$((RANDOM % 61))
# Print the random sleep time
echo "Sleeping for rand ($RANDOM_SLEEP) seconds (cron mode)..."
# Sleep for the random amount of time
sleep $RANDOM_SLEEP
fi
# Run the BGSAVE command
redis-cli bgsave
# Wait for the background save to complete
while true; do
INFO_OUTPUT=$(redis-cli info persistence)
if echo "$INFO_OUTPUT" | grep -q "rdb_bgsave_in_progress:0"; then
break
fi
sleep 1
done
echo "save completed"
# Define the current timestamp
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
# Define the Redis data directory and the backup directory
REDIS_DIR="/var/lib/redis"
BACKUP_DIR="/root/backups/"
# Define the source and destination files
SOURCE_FILE="${REDIS_DIR%/}/dump.rdb"
DEST_FILE="${BACKUP_DIR%/}/aquapool_dump_${TIMESTAMP}.rdb"
# Copy the dump file to the backup location with the timestamp
mv -nv ${SOURCE_FILE} ${DEST_FILE}
echo "Backup created at $DEST_FILE"
# Optionally, delete old backups
find $BACKUP_DIR -type f -name "aquapool_dump_*.rdb" -mtime +5 -exec rm {} \;