vigil rpm 包制作
vigil 可以方便的进行服务的监控,以下尝试制作一个rpm 包,方便使用
安装依赖
- ruby
yum -y install ruby rubygems ruby-devel
- 修改gem 源
可选,如果网络访问没有问题的话
gem sources -a http://mirrors.aliyun.com/rubygems/
gem sources --remove http://rubygems.org/
查看修改后的
gem source list
- 安装fpm
可能会有json 的问题,如果有问题,可以自己安装下
gem install fpm
vigil rpm 构建
- 项目结构
├── res
├── vigil
├── vigil.cfg
├── vigil.service
- 说明
res 是vigil 的模版以及静态资源
vigil 是编译好的linux 二进制文件
vigil.cfg 是一个demo 配置
vigil.service 是使用systemd 管理的service
- 我们rpm的目标
安装完成rpm 包之后vigil.cfg 到/etc/目录
vigil 二进制文件到 /usr/bin
vigil.service systemd service 文件到 /usr/lib/systemd/system/vigil.service
res 到 /etc/vigil 目录 - 使用的命令
fpm -s dir -t rpm -n vigil --config-files /etc/vigil.cfg -v v1.4 \
./vigil=/usr/bin/ \
./vigil.cfg=/etc/ \
./res=/etc/vigil/ \
./vigil.service=/usr/lib/systemd/system/vigil.service
说明:
因为我们制作的是rpm 包,所以t 为rpm -s 指定为dir ,使用配置映射,达到我们上边说到的目的
- 执行效果
fpm -s dir -t rpm -n vigil --config-files /etc/vigil.cfg -v v1.4 \
> ./vigil=/usr/bin/ \
> ./vigil.cfg=/etc/ \
> ./res=/etc/vigil/ \
> ./vigil.service=/usr/lib/systemd/system/vigil.service
Created package {:path=>"vigil-v1.4-1.x86_64.rpm"}
- 查看rpm 的效果
使用 rpm2cpio
rpm2cpio vigil-v1.4-1.x86_64.rpm |cpio -ivd
./etc/vigil.cfg
./etc/vigil/res/assets/fonts/open_sans/open_sans_bold.woff
./etc/vigil/res/assets/fonts/open_sans/open_sans_bold.woff2
./etc/vigil/res/assets/fonts/open_sans/open_sans_light.woff
./etc/vigil/res/assets/fonts/open_sans/open_sans_light.woff2
./etc/vigil/res/assets/fonts/open_sans/open_sans_regular.woff
./etc/vigil/res/assets/fonts/open_sans/open_sans_regular.woff2
./etc/vigil/res/assets/fonts/open_sans/open_sans_semibold.woff
./etc/vigil/res/assets/fonts/open_sans/open_sans_semibold.woff2
./etc/vigil/res/assets/images/badges/color-dead-default.svg
./etc/vigil/res/assets/images/badges/color-healthy-default.svg
./etc/vigil/res/assets/images/badges/color-sick-default.svg
./etc/vigil/res/assets/images/badges/icon-dead-default.svg
./etc/vigil/res/assets/images/badges/icon-dead-large.svg
./etc/vigil/res/assets/images/badges/icon-healthy-default.svg
./etc/vigil/res/assets/images/badges/icon-healthy-large.svg
./etc/vigil/res/assets/images/badges/icon-sick-default.svg
./etc/vigil/res/assets/images/badges/icon-sick-large.svg
./etc/vigil/res/assets/javascripts/index.js
./etc/vigil/res/assets/public/robots.txt
./etc/vigil/res/assets/stylesheets/common.css
./etc/vigil/res/assets/stylesheets/index.css
./etc/vigil/res/assets/templates/index.tera
./usr/bin/vigil
./usr/lib/systemd/system/vigil.service
安装&&使用制作好的rpm
- 安装
yum install -y vigil-v1.4-1.x86_64.rpm
已加载插件:fastestmirror
正在检查 vigil-v1.4-1.x86_64.rpm: vigil-v1.4-1.x86_64
vigil-v1.4-1.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 vigil.x86_64.0.v1.4-1 将被 安装
--> 解决依赖关系完成
依赖关系解决
=======================================================================================================================
Package 架构 版本 源 大小
=======================================================================================================================
正在安装:
vigil x86_64 v1.4-1 /vigil-v1.4-1.x86_64 8.4 M
事务概要
=======================================================================================================================
安装 1 软件包
总计:8.4 M
安装大小:8.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : vigil-v1.4-1.x86_64 1/1
验证中 : vigil-v1.4-1.x86_64 1/1
已安装:
vigil.x86_64 0:v1.4-1
完毕!
- 启动服务
systemctl start vigil
说明
以上只是简单的一个rpm 的制作,同时代码我也已经放到GitHub 上了,对于vigil 的配置可以参考官方文档
同时这个vigil 二进制是我添加了多人邮件发送构建之后的
参考资料
https://github.com/rongfengliang/vigil-rpm
https://github.com/valeriansaliou/vigil
https://github.com/rongfengliang/myvigil-multiemail
https://fpm.readthedocs.io