mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-06 01:22:16 +00:00
chore(log): cap container log growth and echo the resolved config
P2 of the logging plan (the README recipe landed with the code change): - `docker-compose.yml.example`: one `x-logging` anchor applied to all three services. json-file grows without limit by default, so a long-running bot and the proxy in front of it fill the disk; capped at 10m × 3 files. - The startup `config:` line now reports what the process actually resolved — the state DB path (a mistyped `DATA_DIR` or a surprising CWD was invisible until it bit), both TTLs, the caption-quote setting (`off` rather than a bare `0`) and whether a proxy is configured. The proxy URL is never printed (it may embed credentials) and admin ids — chat identifiers — stay at `debug`. Verified: `docker compose config -q` accepts the file, and a scripted fake-API run shows `caption quote off` / `link cache TTL 3600s` under overrides, `proxy=yes` with no credential in any line, and the ids at `debug` only.
This commit is contained in:
@@ -15,6 +15,8 @@ mod urls;
|
||||
pub use callback::callback_query_handler;
|
||||
pub use commands::register_commands;
|
||||
pub use inline::inline_query_handler;
|
||||
/// The resolved `$DATA_DIR/task_queue.db` path, for the startup config line.
|
||||
pub(crate) use statics::db_path;
|
||||
pub use statics::{CHAT_STORE, CONFIG, LINK_CACHE, TASK_QUEUE};
|
||||
pub use urls::{start_url_workers, stop_url_workers};
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ static DB: LazyLock<Arc<db::DbPool>> = LazyLock::new(|| {
|
||||
/// create parent dirs, so the old hardcoded `data/task_queue.db` failed with
|
||||
/// a confusing error when started from a directory without `data/`, and a
|
||||
/// CWD-relative path is a footgun for systemd / cron deployments — `DATA_DIR`
|
||||
/// lets them pin the state anywhere.
|
||||
fn db_path() -> std::path::PathBuf {
|
||||
/// lets them pin the state anywhere. Also read by the startup config line, so
|
||||
/// the log says where the state actually landed.
|
||||
pub(crate) fn db_path() -> std::path::PathBuf {
|
||||
let dir = std::env::var("DATA_DIR").unwrap_or_else(|_| "data".to_string());
|
||||
let dir_path = std::path::Path::new(&dir);
|
||||
std::fs::create_dir_all(dir_path).expect("failed to create data directory");
|
||||
|
||||
Reference in New Issue
Block a user