【问题标题】:On chef, using poise-service and poise-monit, how do I use systemd as the underlying在 chef 上,使用 poise-service 和 poise-monit,我如何使用 systemd 作为底层
【发布时间】:2017-11-02 01:04:26
【问题描述】:

我的根本问题是使用术语提供者。 Monit 是一个运行和监控服务状态的提供者。但是 monit 又依赖于系统上的 provider 来启动和停止服务 - sysinitv、upstart、systemd。

来自cookbooks/poise-monit我明白了

服务提供者

包含监视服务提供程序以允许 poise_service 资源以使用 Monit 作为服务管理器。这使用正常的 来自 poise-service 的 sysvinit 提供程序来生成初始化脚本,但是 通过 Monit 管理服务状态。

现在,我要做的是管理各种进程,例如通过 Monit 管理状态的 redis-server,但 systemd 负责底层管道。

我应该这样做吗:

#configuration file for redis
fnp_redis_conf = "#{node['redis']['conf_dir']}/redis.conf"

template fnp_redis_conf do
  source        "redis.conf.erb"
  owner         "root"
  group         "root"
  mode          "0644"
  variables     :redis => node['redis'], :redis_server => node['redis']['server']
end

#instructions for systemd
poise_service 'redis-server' do
  provider Chef::Provider::Service::Systemd
  command '/usr/local/bin/redis-server #{fnp_redis_conf}'
end

#instructions for monit to call on systemd
poise_service 'redis-server' do
  command 'systemctl start redis-server'
  provider :monit
end

很高兴:在systemd 下而不是通过/etc/init.d/monit 开始监控自身

环境:

macos 12 host
Ubuntu 16.04 guest
Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

【问题讨论】:

    标签: chef-infra monit


    【解决方案1】:

    您必须创建自己的服务提供者类,因为https://github.com/poise/poise-monit/blob/master/lib/poise_monit/service_providers/monit.rb 100% 硬连线到 sysvinit 样式(由于是它的子类)。我想我认为一起使用 monit 和 systemd 没有什么意义,systemd 已经跟踪失败的单元并重新启动它们。您可以在 Chef community slack 上更直接地与我联系。

    【讨论】:

      猜你喜欢
      • 2018-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-22
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多