#服务 #Web 服务器 #可用性 #toml 配置 #CLI

应用 totmannschalter

当无法访问 URL 或返回错误时,会通过邮件通知您的服务

4 个版本

0.1.4 2020 年 9 月 6 日
0.1.3 2020 年 9 月 6 日
0.1.1 2020 年 9 月 6 日
0.1.0 2020 年 9 月 6 日

#229电子邮件

MIT 许可证

24KB
441 代码行

Rust

totmannschalter

一个简单的基于 Rust 的服务,它可以以不同的间隔监控多个 HTTP(s) 端点,如果服务宕机,则会通知管理员。一旦服务恢复,还会发送另一条通知。“Totmannschalter”在德语中意为“自动开关”——一种在信号缺失时停止操作或发送通知的装置。在火车上,这是一种需要定期按压的开关,以确保操作人员仍然清醒和清醒。

功能

  • 每个端点配置,例如间隔和联系邮箱
  • 基于 toml 的配置
  • 发送错误消息,如果服务恢复正常,还将提供服务宕机时间的详细信息

安装

使用 Rust cargo

  1. 确保您已安装 Rust
  2. 运行 cargo install totmannschalter

现在您应该可以直接从 CLI 运行 totmannschalter。如果您想将其作为系统服务(例如在系统启动时运行)运行,您必须自己创建一个(如果您不在使用 systemd 的操作系统上)或安装仓库中现有的 totmannschalter.service 文件,如下所示

# Run as root so the config will be created in the right place
sudo totmannschalter

# Setup the config (your path could be different!)
sudo vim /etc/totmannschalter/config.toml

# Download the service file
wget https://raw.githubusercontent.com/atoav/totmannschalter/master/totmannschalter.service

# Find out where your totmannschalter is installed
which totmannschalter

# Use the output from the which command above and replace the path 
# right of ExecStar in the systemd unit file:
vim totmannschalter.service

# Copy the unit file to your services
sudo cp totmannschalter.services /etc/systemd/system/

# Enable the service (so it runs automatically after the next system startup)
sudo systemctl enable totmannschalter

# Start the service (so it starts right away)
sudo systemctl start totmannschalter

# Check what is going on
journalctl -fu totmannschalter

使用 Debian 软件包 (.deb)

自己构建软件包

  1. 确保您已安装 cargo
  2. 使用 cargo install cargo-deb 安装 cargo-deb
  3. 在仓库根目录下运行 cargo deb
  4. 转到 target/debian/
  5. 使用 sudo dpkg 安装软件包,如下所示:sudo dpkg -i totmanschalter<TAB>
  6. 确保在启用服务之前至少运行一次 sudo totmannschalter,以便创建默认的配置文件。或者,您也可以以普通用户身份作为服务运行 totmannschalter,然后您需要创建自己的用户服务文件,并跳过其余步骤
  7. 启用服务:sudo systemctl enable totmannschalter
  8. 启动服务:sudo systemctl start totmannschalter
  9. 检查服务状态:systemctl status totmannschalterjournalctl -fu totmannschalter

使用发行版构建

查看 GitHub 发布页面 : )

依赖关系

~8–22MB
~343K SLoC