Skip to content

Commit

Permalink
Finish README.
Browse files Browse the repository at this point in the history
  • Loading branch information
orium committed Dec 20, 2023
1 parent 9e5cc8e commit 53cad65
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ In Brewfather you need to enable the "Custom Stream" integration in the

### Systemd daemon

WIP!
To make Brewfatherlog a systemd service that will start automatically create file
`/etc/systemd/system/brewfatherlog.service` with the content (replace the user and the path to the brewfatherlog
binary):

```ini
[Unit]
Description=Log temperatures from grainfather fermenters to brewfather
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=1
User=<USER>
ExecStart=<PATH TO brewfatherlog>

[Install]
WantedBy=multi-user.target
```

and then enable and start the service:

```bash
systemctl enable brewfatherlog
systemctl start brewfatherlog
```

<!-- cargo-rdme end -->
34 changes: 32 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,32 @@
//!
//! ## Systemd daemon
//!
//! WIP!
//! To make Brewfatherlog a systemd service that will start automatically create file
//! `/etc/systemd/system/brewfatherlog.service` with the content (replace the user and the path to the brewfatherlog
//! binary):
//!
//! ```ini
//! [Unit]
//! Description=Log temperatures from grainfather fermenters to brewfather
//! After=network.target
//!
//! [Service]
//! Type=simple
//! Restart=always
//! RestartSec=1
//! User=<USER>
//! ExecStart=<PATH TO brewfatherlog>
//!
//! [Install]
//! WantedBy=multi-user.target
//! ```
//!
//! and then enable and start the service:
//!
//! ```bash
//! systemctl enable brewfatherlog
//! systemctl start brewfatherlog
//! ```
mod config;

Expand All @@ -47,6 +72,7 @@ use time::OffsetDateTime;
use tokio::time::sleep;

pub const PROGRAM_NAME: &str = env!("CARGO_PKG_NAME");
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

fn program_dir_path() -> PathBuf {
let home_dir: PathBuf = dirs::home_dir().expect("Unable to get home directory");
Expand Down Expand Up @@ -135,7 +161,7 @@ async fn main_loop(config: Config) -> ! {
let init_grainfather =
|| Grainfather::new(&config.grainfather.auth.email, &config.grainfather.auth.password);

info!("Starting {}.", PROGRAM_NAME);
info!("Starting {} v{}.", PROGRAM_NAME, VERSION);

let mut last_logged: HashMap<FermenterId, OffsetDateTime> = HashMap::new();

Expand All @@ -161,6 +187,10 @@ async fn main_loop(config: Config) -> ! {
}
};

if ferms.is_empty() {
info!("No fermenters found.");
}

for ferm in ferms {
let temp_record = match grainfather.get_fermenter_temperature(ferm.id).await {
Ok(Some(temp)) => temp,
Expand Down

0 comments on commit 53cad65

Please sign in to comment.