🚀 EPUSDT(Go版)一键部署脚本
环境准备
适用:Ubuntu 20/22/24 / Debian 11+
模式:源码编译 + Supervisor 守护
默认路径:/www/wwwroot/epusdt
一键脚本
#!/bin/bash
set -e
APP_NAME="epusdt"
APP_DIR="/www/wwwroot/${APP_NAME}"
BINARY_NAME="epusdt"
REPO="https://github.com/epusdt/epusdt.git"
echo "=============================="
echo " EPUSDT Go + SQLite 一键部署"
echo "=============================="
# 1. 系统依赖
apt update -y
apt install -y git curl wget unzip supervisor nginx
# 2. 安装 Go(如未安装)
if ! command -v go &> /dev/null; then
echo "安装 Go..."
GO_VERSION="1.25.0"
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
source /etc/profile
fi
# 3. 创建目录
mkdir -p ${APP_DIR}
cd ${APP_DIR}
# 4. 拉取代码
if [ -d ".git" ]; then
git pull
else
git clone ${REPO} .
fi
# 5. 编译
echo "编译Go程序..."
cd src
go mod tidy || true
go build -o ${BINARY_NAME} .
# 6. 创建运行目录
mkdir -p logs runtime static
# 7. 写入最小 .env(SQLite版本)
# 生成强随机 API Token
API_TOKEN=$(openssl rand -hex 32)
cat > .env <<EOF
app_name=epusdt
app_uri=http://127.0.0.1:8000
log_level=info
http_access_log=false
sql_debug=false
http_listen=:8000
static_path=/static
runtime_root_path=./runtime
log_save_path=./logs
log_max_size=32
log_max_age=7
max_backups=3
db_type=sqlite
sqlite_database_filename=
sqlite_table_prefix=
runtime_sqlite_filename=epusdt-runtime.db
queue_concurrency=10
queue_poll_interval_ms=1000
callback_retry_base_seconds=5
tg_bot_token=
tg_proxy=
tg_manage=
# 自动生成安全密钥
api_auth_token=${API_TOKEN}
order_expiration_time=10
order_notice_max_retry=0
forced_usdt_rate=
api_rate_url=
tron_grid_api_key=
EOF
echo "=============================="
echo " API_TOKEN 已生成:"
echo "${API_TOKEN}"
echo "=============================="
# 8. 权限
chmod +x ${BINARY_NAME}
# 9. Supervisor 配置
cat > /etc/supervisor/conf.d/epusdt.conf <<EOF
[program:epusdt]
directory=${APP_DIR}
command=${APP_DIR}/${BINARY_NAME}
autostart=true
autorestart=true
startsecs=5
user=root
redirect_stderr=true
stdout_logfile=${APP_DIR}/logs/app.log
stopasgroup=true
killasgroup=true
EOF
# 10. Nginx(可选反代)
cat > /etc/nginx/sites-available/epusdt.conf <<EOF
server {
listen 80;
server_name _;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
}
}
EOF
ln -sf /etc/nginx/sites-available/epusdt.conf /etc/nginx/sites-enabled/
# 11. 启动服务
systemctl restart nginx
supervisorctl reread
supervisorctl update
supervisorctl restart epusdt || supervisorctl start epusdt
systemctl enable supervisor
systemctl enable nginx
echo "=============================="
echo " 部署完成"
echo " 地址: http://服务器IP"
echo " 端口: 8000"
echo "=============================="
⚙️ 脚本做了什么
- 自动日志输出
- 安装 Go 环境(如果没有)
- 拉取 EPUSDT Go 源码
- 自动编译二进制文件
- Supervisor 守护进程托管
- Nginx 反向代理
📌 版权声明
文章作者:大神K
版权说明:本文为原创内容,转载请注明出处。