Sync your own workout data from your "Strong" app
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixed cronjob

tolik518 4209d081 167a456d

+34 -22
+4 -4
Cargo.lock
··· 181 181 ] 182 182 183 183 [[package]] 184 - name = "dotenv" 185 - version = "0.15.0" 184 + name = "dotenvy" 185 + version = "0.15.7" 186 186 source = "registry+https://github.com/rust-lang/crates.io-index" 187 - checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" 187 + checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" 188 188 189 189 [[package]] 190 190 name = "encoding_rs" ··· 1233 1233 version = "0.1.0" 1234 1234 dependencies = [ 1235 1235 "clickhouse", 1236 - "dotenv", 1236 + "dotenvy", 1237 1237 "reqwest", 1238 1238 "serde", 1239 1239 "serde_json",
+7 -8
Dockerfile
··· 1 1 FROM rust:bookworm AS builder 2 2 WORKDIR /usr/src/strong-api-fetch 3 3 COPY . . 4 - RUN cd strong-api-fetch && cargo install --path . 4 + RUN cd strong-api-fetch && RUSTFLAGS="-C debuginfo=2" cargo install --path . --debug 5 5 6 6 FROM debian:bookworm-slim 7 7 RUN apt-get update && apt-get install -y \ ··· 12 12 13 13 WORKDIR /usr/strong-api-fetch 14 14 COPY --from=builder /usr/local/cargo/bin/strong-api-fetch /usr/bin/strong-api-fetch 15 - 15 + COPY .env /.env 16 16 # will run the cron job every day at 18:00, 18:30, 19:00, 19:30, 20:00, and 20:30 17 - RUN echo "0,30 18-20 * * * root /usr/bin/strong-api-fetch >> /var/log/cron.log 2>&1" > /etc/cron.d/strong-api-fetch 17 + RUN echo "0,30 02-03 * * * root RUST_BACKTRACE=1 RUST_LOG=debug /usr/bin/strong-api-fetch >> /var/log/cron.log 2>&1" > /etc/cron.d/strong-api-fetch 18 18 19 19 # Ensure the cron job file has proper permissions 20 20 RUN chmod 0644 /etc/cron.d/strong-api-fetch && \ 21 21 chmod +x /usr/bin/strong-api-fetch 22 22 23 - # Install the new cron job 24 - RUN crontab /etc/cron.d/strong-api-fetch 25 - 26 23 # Create the log file so that it exists when cron writes to it 27 24 RUN touch /var/log/cron.log 28 25 29 - # Run cron in the foreground 30 - CMD ["cron", "-f"] 26 + COPY docker-entrypoint.sh /docker-entrypoint.sh 27 + RUN chmod +x /docker-entrypoint.sh 28 + 29 + CMD ["/docker-entrypoint.sh"]
+5
docker-entrypoint.sh
··· 1 + #!/bin/bash 2 + # Start cron in the background 3 + cron 4 + # Follow the log file and output to stdout 5 + tail -f /var/log/cron.log
+1 -1
strong-api-fetch/Cargo.toml
··· 5 5 6 6 [dependencies] 7 7 strong-api-lib = { path = "../strong-api-lib" } 8 - dotenv = "0.15" 8 + dotenvy = "0.15" 9 9 reqwest = "0.12.14" 10 10 serde_json = "1.0" 11 11 tokio = { version = "1", features = ["full"] }
+17 -9
strong-api-fetch/src/main.rs
··· 1 1 mod clickhouse_saver; 2 2 3 - use dotenv::dotenv; 3 + use dotenvy::dotenv; 4 4 use reqwest::Url; 5 5 use std::env; 6 6 use std::fs; ··· 69 69 /// Load configuration values from environment variables. 70 70 fn load_config() -> Result<Config, Box<dyn std::error::Error>> { 71 71 Ok(Config { 72 - username: env::var("STRONG_USER")?, 73 - password: env::var("STRONG_PASS")?, 74 - strong_backend: env::var("STRONG_BACKEND")?, 75 - clickhouse_url: env::var("CLICKHOUSE_URL")?, 76 - clickhouse_user: env::var("CLICKHOUSE_USER")?, 77 - clickhouse_pass: env::var("CLICKHOUSE_PASS")?, 78 - clickhouse_database: env::var("CLICKHOUSE_DATABASE")?, 79 - clickhouse_table: env::var("CLICKHOUSE_TABLE")?, 72 + username: env::var("STRONG_USER") 73 + .expect("STRONG_USER must be set"), 74 + password: env::var("STRONG_PASS") 75 + .expect("STRONG_PASS must be set"), 76 + strong_backend: env::var("STRONG_BACKEND") 77 + .expect("STRONG_BACKEND must be set"), 78 + clickhouse_url: env::var("CLICKHOUSE_URL") 79 + .expect("CLICKHOUSE_URL must be set"), 80 + clickhouse_user: env::var("CLICKHOUSE_USER") 81 + .expect("CLICKHOUSE_USER must be set"), 82 + clickhouse_pass: env::var("CLICKHOUSE_PASS") 83 + .expect("CLICKHOUSE_PASS must be set"), 84 + clickhouse_database: env::var("CLICKHOUSE_DATABASE") 85 + .expect("CLICKHOUSE_DATABASE must be set"), 86 + clickhouse_table: env::var("CLICKHOUSE_TABLE") 87 + .expect("CLICKHOUSE_TABLE must be set"), 80 88 }) 81 89 } 82 90