Skip to content

Commit

Permalink
Merge pull request #74 from tmknight/develop
Browse files Browse the repository at this point in the history
v0.8.1
  • Loading branch information
tmknight authored Feb 8, 2024
2 parents c6291db + e2878f6 commit 267283b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

## 0.8.1

### Changed

- Small change to how webhook and/or apprise are called for the sake of efficiency
- Updated license to GPL-3.0

## 0.8.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "docker-autoheal"
version = "0.8.0"
version = "0.8.1"
authors = ["Travis M Knight"]
license = "MIT"
license = "GPL-3.0"
description = "A cross-platform tool to monitor and remediate unhealthy Docker containers"
readme = "README.md"
homepage = "https://github.com/tmknight/docker-autoheal"
edition = "2021"
rust-version = "1.74.1"
rust-version = "1.74"

[dependencies]
bollard = { version = "0.*", features = ["ssl"] }
Expand Down
43 changes: 16 additions & 27 deletions src/execute/looper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,16 @@ pub async fn start_loop(
log_message(&msg1, WARNING).await;

// Restart unhealthy container
match &docker_clone.restart_container(&id, restart_options).await {
let msg = match &docker_clone.restart_container(&id, restart_options).await
{
Ok(()) => {
// Log result
let msg0 = format!(
"[{}] Restart of container ({}) was successful",
name, id
);
log_message(&msg0, INFO).await;
// Send webhook
if !(webhook_url.is_empty() && webhook_key.is_empty()) {
let payload = format!("{{\"{}\":\"{}\"}}", &webhook_key, &msg0);
notify_webhook(&webhook_url, &payload).await;
}
// Send apprise
if !apprise_url.is_empty() {
let payload = format!(
"{{\"title\":\"Docker-Autoheal\",\"body\":\"{}\"}}",
&msg0
);
notify_webhook(&apprise_url, &payload).await;
}
msg0
}
Err(e) => {
// Log result
Expand All @@ -122,20 +111,20 @@ pub async fn start_loop(
name, id, e
);
log_message(&msg0, ERROR).await;
// Send webhook
if !(webhook_url.is_empty() && webhook_key.is_empty()) {
let payload = format!("{{\"{}\":\"{}\"}}", &webhook_key, &msg0);
notify_webhook(&webhook_url, &payload).await;
}
// Send apprise
if !apprise_url.is_empty() {
let payload = format!(
"{{\"title\":\"Docker-Autoheal\",\"body\":\"{}\"}}",
&msg0
);
notify_webhook(&apprise_url, &payload).await;
}
msg0
}
};

// Send webhook
if !(webhook_url.is_empty() && webhook_key.is_empty()) {
let payload = format!("{{\"{}\":\"{}\"}}", &webhook_key, &msg);
notify_webhook(&webhook_url, &payload).await;
}
// Send apprise
if !apprise_url.is_empty() {
let payload =
format!("{{\"title\":\"Docker-Autoheal\",\"body\":\"{}\"}}", &msg);
notify_webhook(&apprise_url, &payload).await;
}
}
}
Expand Down

0 comments on commit 267283b

Please sign in to comment.