增加对 1GB Huge Pages 的支持,添加相关服务和配置,优化安装脚本
Build and Release / build-and-test (amd64) (push) Successful in 1m40s
Build and Release / build-and-test (arm64) (push) Successful in 1m40s
Build and Release / release (push) Failing after 4s

This commit is contained in:
2026-08-05 12:50:18 +08:00
parent 99a17f1852
commit b04d41d783
7 changed files with 49 additions and 75 deletions
+5
View File
@@ -46,6 +46,7 @@ PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
mkdir -p "${PKG_DIR}/DEBIAN" mkdir -p "${PKG_DIR}/DEBIAN"
mkdir -p "${PKG_DIR}/opt/xxxig" mkdir -p "${PKG_DIR}/opt/xxxig"
mkdir -p "${PKG_DIR}/lib/systemd/system" mkdir -p "${PKG_DIR}/lib/systemd/system"
mkdir -p "${PKG_DIR}/usr/libexec"
# 解压二进制文件 # 解压二进制文件
echo "📂 Extracting binaries..." echo "📂 Extracting binaries..."
@@ -70,6 +71,8 @@ chmod 755 "${PKG_DIR}/DEBIAN/postrm"
echo "🔧 Installing systemd services..." echo "🔧 Installing systemd services..."
cp debian/xxxig-server.service "${PKG_DIR}/lib/systemd/system/" cp debian/xxxig-server.service "${PKG_DIR}/lib/systemd/system/"
cp debian/xxxig-daemon.service "${PKG_DIR}/lib/systemd/system/" cp debian/xxxig-daemon.service "${PKG_DIR}/lib/systemd/system/"
cp debian/xxxig-hugepages.service "${PKG_DIR}/lib/systemd/system/"
cp debian/xxxig-enable-1gb-pages "${PKG_DIR}/usr/libexec/"
# 设置权限 # 设置权限
chmod 755 "${PKG_DIR}/opt/xxxig/xxxigServer" chmod 755 "${PKG_DIR}/opt/xxxig/xxxigServer"
@@ -80,6 +83,8 @@ chmod 644 "${PKG_DIR}/opt/xxxig/config_cc.json"
chmod 644 "${PKG_DIR}/opt/xxxig/index.html" chmod 644 "${PKG_DIR}/opt/xxxig/index.html"
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-server.service" chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-server.service"
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-daemon.service" chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-daemon.service"
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-hugepages.service"
chmod 755 "${PKG_DIR}/usr/libexec/xxxig-enable-1gb-pages"
# 构建 deb 包 # 构建 deb 包
echo "🔨 Building package..." echo "🔨 Building package..."
+1 -1
View File
@@ -3,7 +3,7 @@ Version: {{VERSION}}
Section: net Section: net
Priority: optional Priority: optional
Architecture: {{ARCH}} Architecture: {{ARCH}}
Depends: libc6 (>= 2.31) Depends: libc6 (>= 2.31), procps
Maintainer: XXXig Team <noreply@example.com> Maintainer: XXXig Team <noreply@example.com>
Homepage: https://github.com/wangdefaa/xxxig Homepage: https://github.com/wangdefaa/xxxig
Description: Cryptocurrency mining software suite Description: Cryptocurrency mining software suite
+1 -1
View File
@@ -3,7 +3,7 @@ set -e
# 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行与开机自启状态 # 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行与开机自启状态
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
for service in xxxig-server.service xxxig-daemon.service; do for service in xxxig-server.service xxxig-daemon.service xxxig-hugepages.service; do
if systemctl is-active --quiet "$service"; then if systemctl is-active --quiet "$service"; then
echo "Stopping $service..." echo "Stopping $service..."
systemctl stop "$service" systemctl stop "$service"
+3 -2
View File
@@ -1,6 +1,7 @@
[Unit] [Unit]
Description=XXXig Daemon (Miner Client) Description=XXXig Daemon (Miner Client)
After=network.target Requires=xxxig-hugepages.service
After=network.target xxxig-hugepages.service
[Service] [Service]
Type=simple Type=simple
@@ -24,7 +25,7 @@ NoNewPrivileges=true
PrivateTmp=true PrivateTmp=true
ProtectSystem=strict ProtectSystem=strict
ProtectHome=true ProtectHome=true
ReadWritePaths=/var/log/xxxig ReadWritePaths=/var/log/xxxig /etc/xxxig
# 日志设置 # 日志设置
StandardOutput=journal StandardOutput=journal
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
set -eu
sysctl -w vm.nr_hugepages="$(nproc)"
found=0
for node in /sys/devices/system/node/node*; do
file="$node/hugepages/hugepages-1048576kB/nr_hugepages"
[ -e "$file" ] || continue
printf '3\n' >"$file"
actual=$(cat "$file")
[ "$actual" -ge 3 ] || exit 1
found=1
done
[ "$found" -eq 1 ]
+9
View File
@@ -0,0 +1,9 @@
[Unit]
Description=Reserve Huge Pages for XXXig
Before=xxxig-daemon.service
ConditionPathExists=/etc/xxxig/1gb-pages.enabled
ConditionPathExists=/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
[Service]
Type=oneshot
ExecStart=/usr/libexec/xxxig-enable-1gb-pages
+14 -71
View File
@@ -16,10 +16,10 @@ declare -r RESET="\033[0m"
CONFIG_DIR="/etc/xxxig" CONFIG_DIR="/etc/xxxig"
LOG_DIR="/var/log/xxxig" LOG_DIR="/var/log/xxxig"
CONFIG_FILE="$CONFIG_DIR/config.json" CONFIG_FILE="$CONFIG_DIR/config.json"
HUGEPAGES_HELPER="/usr/local/libexec/xxxig-enable-1gb-pages" HUGEPAGES_MARKER="$CONFIG_DIR/1gb-pages.enabled"
HUGEPAGES_SERVICE="/etc/systemd/system/xxxig-hugepages.service" LEGACY_HUGEPAGES_HELPER="/usr/local/libexec/xxxig-enable-1gb-pages"
DAEMON_DROPIN_DIR="/etc/systemd/system/xxxig-daemon.service.d" LEGACY_HUGEPAGES_SERVICE="/etc/systemd/system/xxxig-hugepages.service"
DAEMON_DROPIN="$DAEMON_DROPIN_DIR/installer.conf" LEGACY_DAEMON_DROPIN="/etc/systemd/system/xxxig-daemon.service.d/installer.conf"
# Gitea 配置 # Gitea 配置
GITEA_SERVER="gitea.bcde.io" GITEA_SERVER="gitea.bcde.io"
@@ -66,11 +66,10 @@ add_apt_repository() {
# 卸载旧版本 # 卸载旧版本
uninstall_xxxig() { uninstall_xxxig() {
systemctl stop xxxig-daemon xxxig-server xxxig-hugepages 2>/dev/null || true systemctl stop xxxig-daemon xxxig-server 2>/dev/null || true
systemctl disable xxxig-daemon xxxig-server xxxig-hugepages 2>/dev/null || true systemctl disable xxxig-daemon xxxig-server 2>/dev/null || true
apt-get remove -y xxxig 2>/dev/null || true apt-get remove -y xxxig 2>/dev/null || true
rm -rf "$CONFIG_DIR" "$LOG_DIR" /etc/apt/sources.list.d/xxxig.list rm -rf "$CONFIG_DIR" "$LOG_DIR" "/etc/apt/sources.list.d/${GITEA_OWNER}.list"
rm -f "$HUGEPAGES_HELPER" "$HUGEPAGES_SERVICE" "$DAEMON_DROPIN"
systemctl daemon-reload 2>/dev/null || true systemctl daemon-reload 2>/dev/null || true
} }
@@ -86,75 +85,19 @@ install_xxxig() {
log "$GREEN" "安装完成" log "$GREEN" "安装完成"
} }
write_hugepages_helper() {
mkdir -p "$(dirname "$HUGEPAGES_HELPER")"
cat >"$HUGEPAGES_HELPER" <<'EOF'
#!/bin/sh
set -eu
sysctl -w vm.nr_hugepages="$(nproc)"
found=0
for node in /sys/devices/system/node/node*; do
file="$node/hugepages/hugepages-1048576kB/nr_hugepages"
[ -e "$file" ] || continue
printf '3\n' >"$file"
actual=$(cat "$file")
[ "$actual" -ge 3 ] || exit 1
found=1
done
[ "$found" -eq 1 ]
EOF
chmod 755 "$HUGEPAGES_HELPER"
}
write_hugepages_service() {
cat >"$HUGEPAGES_SERVICE" <<EOF
[Unit]
Description=Reserve Huge Pages for XXXig
Before=xxxig-daemon.service
ConditionPathExists=/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
[Service]
Type=oneshot
ExecStart=$HUGEPAGES_HELPER
[Install]
WantedBy=multi-user.target
EOF
}
write_daemon_dropin() {
mkdir -p "$DAEMON_DROPIN_DIR"
{
echo "[Unit]"
if [[ "$one_gb_pages" == "true" ]]; then
echo "Requires=xxxig-hugepages.service"
echo "After=xxxig-hugepages.service"
fi
echo
echo "[Service]"
echo "ReadWritePaths=$LOG_DIR $CONFIG_DIR"
} >"$DAEMON_DROPIN"
}
configure_hugepages() { configure_hugepages() {
write_daemon_dropin if [[ "$one_gb_pages" == "true" ]]; then
[[ "$one_gb_pages" == "true" ]] || return 0 touch "$HUGEPAGES_MARKER"
chmod 644 "$HUGEPAGES_MARKER"
log "$BLUE" "配置 1GB Huge Pages 持久池..." log "$GREEN" "已启用 DEB 包内置的 1GB Huge Pages 服务"
write_hugepages_helper else
write_hugepages_service rm -f "$HUGEPAGES_MARKER"
log "$GREEN" "1GB Huge Pages 初始化服务配置完成" fi
} }
start_service() { start_service() {
log "$BLUE" "启动服务..." log "$BLUE" "启动服务..."
systemctl daemon-reload systemctl daemon-reload
if [[ "$one_gb_pages" == "true" ]]; then
systemctl enable xxxig-hugepages.service
fi
systemctl enable --now xxxig-daemon.service systemctl enable --now xxxig-daemon.service
} }