Haruka041 commited on
Commit ·
3a1d7ad
1
Parent(s): 6f99e03
fix: remove bot TcpListener (nginx owns 7860), mkdir nginx log dir
Browse files- Dockerfile +3 -2
- src/ui/telegram/mod.rs +0 -18
Dockerfile
CHANGED
|
@@ -20,13 +20,14 @@ FROM alpine:3.21
|
|
| 20 |
RUN apk add --no-cache nginx openssl ca-certificates
|
| 21 |
|
| 22 |
RUN mkdir -p /app/data /app/logs /app/cache /app/downloads /app/html /tmp/nginx && \
|
| 23 |
-
mkdir -p /tmp/nginx/client_body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi
|
|
|
|
| 24 |
|
| 25 |
COPY --from=builder /build/target/release/tomato-novel-downloader /app/bot
|
| 26 |
COPY nginx.conf /etc/nginx/nginx.conf
|
| 27 |
COPY fake_error.html /app/html/fake_error.html
|
| 28 |
|
| 29 |
-
RUN chown -R 1000:1000 /app /tmp/nginx && chmod -R 755 /app /tmp/nginx
|
| 30 |
|
| 31 |
EXPOSE 7860
|
| 32 |
USER 1000
|
|
|
|
| 20 |
RUN apk add --no-cache nginx openssl ca-certificates
|
| 21 |
|
| 22 |
RUN mkdir -p /app/data /app/logs /app/cache /app/downloads /app/html /tmp/nginx && \
|
| 23 |
+
mkdir -p /tmp/nginx/client_body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi && \
|
| 24 |
+
mkdir -p /var/lib/nginx/logs
|
| 25 |
|
| 26 |
COPY --from=builder /build/target/release/tomato-novel-downloader /app/bot
|
| 27 |
COPY nginx.conf /etc/nginx/nginx.conf
|
| 28 |
COPY fake_error.html /app/html/fake_error.html
|
| 29 |
|
| 30 |
+
RUN chown -R 1000:1000 /app /tmp/nginx /var/lib/nginx/logs && chmod -R 755 /app /tmp/nginx /var/lib/nginx/logs
|
| 31 |
|
| 32 |
EXPOSE 7860
|
| 33 |
USER 1000
|
src/ui/telegram/mod.rs
CHANGED
|
@@ -43,24 +43,6 @@ fn ensure_user_registered(db: &Database, msg: &Message) {
|
|
| 43 |
pub async fn run(token: String, data_dir: &str) -> Result<()> {
|
| 44 |
tracing::info!(target: "telegram", "Starting Telegram Bot mode...");
|
| 45 |
|
| 46 |
-
// 健康检查 HTTP 服务器(tokio TcpListener,端口 7860)
|
| 47 |
-
tokio::spawn(async {
|
| 48 |
-
let html = b"<html><head><title>502 Bad Gateway</title></head><body><center><h1>502 Bad Gateway</h1></center><hr><center>nginx</center></body></html>";
|
| 49 |
-
let header = format!("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", html.len());
|
| 50 |
-
match tokio::net::TcpListener::bind("0.0.0.0:7860").await {
|
| 51 |
-
Ok(listener) => {
|
| 52 |
-
loop {
|
| 53 |
-
if let Ok((mut stream, _)) = listener.accept().await {
|
| 54 |
-
use tokio::io::AsyncWriteExt;
|
| 55 |
-
let _ = stream.write_all(header.as_bytes()).await;
|
| 56 |
-
let _ = stream.write_all(html).await;
|
| 57 |
-
}
|
| 58 |
-
}
|
| 59 |
-
}
|
| 60 |
-
Err(e) => eprintln!("Health server bind error: {e}"),
|
| 61 |
-
}
|
| 62 |
-
});
|
| 63 |
-
|
| 64 |
let db_path = format!("{}/bot.db", data_dir);
|
| 65 |
let db = Database::open(std::path::Path::new(&db_path))?;
|
| 66 |
let db = Arc::new(db);
|
|
|
|
| 43 |
pub async fn run(token: String, data_dir: &str) -> Result<()> {
|
| 44 |
tracing::info!(target: "telegram", "Starting Telegram Bot mode...");
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
let db_path = format!("{}/bot.db", data_dir);
|
| 47 |
let db = Database::open(std::path::Path::new(&db_path))?;
|
| 48 |
let db = Arc::new(db);
|