diff --git a/README.md b/README.md index 0cfa516..6114280 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,16 @@ ## Usage +### Using nix + +```nix +nix develop # to get the dev dependencies +nix build +nix run -- /tmp/rss/ +``` + +### Using podman + Use the `justfile` to run commands: ```bash @@ -12,35 +22,7 @@ just init # Will init the database, and build the app image just run # Will run the lwn-sub-snoozer to update the database and the RSS file ``` -## Nix setup - -For my server, I have the following setup: - -```nix -systemd.timers."rssify-update" = { - wantedBy = [ "timers.target" ]; - timerConfig = { - OnBootSec = "5m"; - OnUnitActiveSec = "12h"; - Unit = "rssify-update.service"; - }; -}; - -systemd.services."rssify-update" = { - script = '' - ${pkgs.rssify}/bin/echo "Hello World" - ''; - serviceConfig = { - Type = "oneshot"; - User = "root"; - }; -}; -``` - ## TODO -- [ ] Nix service with timer -- [ ] Better path managment, with env variable in Dockerfile -- [ ] Clean repo - [ ] Add volume to the db to store it if it crashes - [ ] Add tests diff --git a/src/bin/cli.rs b/src/bin/cli.rs index c1f9519..64c1139 100755 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -13,20 +13,23 @@ fn main() { let rt = Runtime::new().unwrap(); let args = Cli::parse(); - let db_connection_string = &format!( - "host={} dbname={} user={} password={}", - env::var("POSTGRES_HOST").unwrap_or(String::from("localhost")), - env::var("POSTGRES_USER").unwrap_or(String::from("root")), - env::var("POSTGRES_USER").unwrap_or(String::from("root")), - env::var("POSTGRES_PASSWORD").unwrap_or(String::from("root")) - ); + let db_connection_string = match env::var("DATABASE_CONNECTION") { + Ok(s) => s, + _ => format!( + "host={} dbname={} user={} password={}", + env::var("POSTGRES_HOST").unwrap_or(String::from("localhost")), + env::var("POSTGRES_USER").unwrap_or(String::from("root")), + env::var("POSTGRES_USER").unwrap_or(String::from("root")), + env::var("POSTGRES_PASSWORD").unwrap_or(String::from("root")) + ), + }; println!("Connection string: {}", db_connection_string); rt.block_on(async { // Connect to the database. if let Ok((client, connection)) = - tokio_postgres::connect(db_connection_string, tokio_postgres::NoTls).await + tokio_postgres::connect(&db_connection_string, tokio_postgres::NoTls).await { println!("Working...");