From 7613ac88d99b946fe28b1b17f5371f3b1f664224 Mon Sep 17 00:00:00 2001 From: "Alexander I. Chebykin" Date: Tue, 28 Jun 2022 01:36:02 +0300 Subject: [PATCH] Minor changes. --- README.md | 8 ++++++-- ...-watchdog.service.template => cai-watchdog.service} | 2 +- .../usr/local/bin/{send-mail.template => send-mail} | 0 .../bin/{send-telegram.template => send-telegram} | 0 src/main.rs | 10 +++++++++- 5 files changed, 16 insertions(+), 4 deletions(-) rename scripts/unix/{cai-watchdog.service.template => cai-watchdog.service} (83%) rename scripts/unix/usr/local/bin/{send-mail.template => send-mail} (100%) rename scripts/unix/usr/local/bin/{send-telegram.template => send-telegram} (100%) diff --git a/README.md b/README.md index 4879a70..71c98e9 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,13 @@ Watchdog for monitoring web-services ## Requirements -**On \*nix:** OpenSSL 1.0.1, 1.0.2, 1.1.0, or 1.1.1 with headers (see https://github.com/sfackler/rust-openssl) +###On \*nix +- OpenSSL 1.0.1, 1.0.2, 1.1.0, or 1.1.1 with headers (see https://github.com/sfackler/rust-openssl) +- Perl +- Curl -**On Windows:** Nothing +###On Windows +- PowerShell ## Configuration file diff --git a/scripts/unix/cai-watchdog.service.template b/scripts/unix/cai-watchdog.service similarity index 83% rename from scripts/unix/cai-watchdog.service.template rename to scripts/unix/cai-watchdog.service index d180aec..7034f36 100644 --- a/scripts/unix/cai-watchdog.service.template +++ b/scripts/unix/cai-watchdog.service @@ -5,7 +5,7 @@ Description=Watchdog service User=wwwrun Group=www Type=simple -ExecStart=/usr/local/bin/cai-watchdog +ExecStart=/usr/local/sbin/cai-watchdog KillMode=control-group NotifyAccess=all diff --git a/scripts/unix/usr/local/bin/send-mail.template b/scripts/unix/usr/local/bin/send-mail similarity index 100% rename from scripts/unix/usr/local/bin/send-mail.template rename to scripts/unix/usr/local/bin/send-mail diff --git a/scripts/unix/usr/local/bin/send-telegram.template b/scripts/unix/usr/local/bin/send-telegram similarity index 100% rename from scripts/unix/usr/local/bin/send-telegram.template rename to scripts/unix/usr/local/bin/send-telegram diff --git a/src/main.rs b/src/main.rs index fadf284..d67882e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,10 @@ extern crate ini; extern crate exitcode; use std::env; +use std::path::Path; +use std::process::Command; use std::thread; use std::time::Duration; -use std::process::Command; /// Rule description structure pub struct Rule { @@ -161,6 +162,13 @@ fn main() { "/etc/cai-watchdog.conf" }; + if !Path::new(cfg_file).exists() { + println!("Error! Can't find configuration file."); + println!("Exiting..."); + + std::process::exit(exitcode::CONFIG); + } + let cfg = ini!(cfg_file); let check_interval = cfg["main"]["check_interval"].clone().unwrap().parse::().unwrap() * 1000;