feat: add managed ACME listener and log rotation

This commit is contained in:
chermack
2026-07-26 06:37:49 +08:00
parent 3cd9c2e9c8
commit 084577c910
5 changed files with 31 additions and 4 deletions
+5
View File
@@ -8,4 +8,9 @@ systemctl start trojan
systemctl start trojan-web
systemctl start trojan-acme-challenge
systemctl enable trojan trojan-web trojan-acme-challenge trojan-acme-renew.timer || true
(
while sleep 300; do
/usr/local/sbin/rotate-trojan-log || true
done
) &
exec tail -f /dev/null
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail
log=/var/log/trojan.log
limit=$((20 * 1024 * 1024))
[[ -f "$log" ]] || exit 0
size=$(stat -c %s "$log")
(( size < limit )) && exit 0
rm -f "${log}.5.gz"
for n in 4 3 2 1; do
[[ -f "${log}.${n}.gz" ]] && mv "${log}.${n}.gz" "${log}.$((n + 1)).gz"
done
cp "$log" "${log}.1"
: > "$log"
gzip -f "${log}.1"
@@ -5,7 +5,7 @@ After=network.target
[Service]
Type=simple
Environment=ACME_WEBROOT=/var/lib/trojan-acme-webroot
ExecStart=/bin/sh -c '/usr/local/bin/trojan acme-http --port "${ACME_HTTP_PORT:-8082}"'
ExecStart=/bin/sh -c '/usr/local/bin/trojan acme-http --host "${ACME_HTTP_HOST:-127.0.0.1}" --port "${ACME_HTTP_PORT:-8082}"'
Restart=on-failure
RestartSec=3s