Skip to content

Loading Configuration into the Monitoring Daemon

Gurpartap edited this page Feb 3, 2013 · 12 revisions

Preload process information

To specify processes to be managed, the following may be specified in the cognizantd monitoring daemon's init configuration:

# from examples/cognizantd.yml
applications: {
  example-app: { # Identifying container app name.
    # pids_dir: /var/run/example-app/,
    # logs_dir: /var/log/example-app/,
    monitor: {
      redis-server-1: { # Identifying process name.
        group: redis,
        start_command: /usr/local/bin/redis-server -,
        start_with_input: "daemonize no\nport 6666",
        ping_command: redis-cli -p 6666 PING,
        stop_signals: [TERM, INT]
      },
      sleep: {
        start_command: sleep 3
      }
    }
  }
}

Ruby configuration format can be utilized by specifying the files to load in the YAML config like:

load:
  - /path/to/example-app.rb
  - /path/to/another-app.rb

See the following example for Ruby format.

Hot-loading process information

Process information can also be provided via Ruby code. However, it is currently unavailable through the cognizantd daemon. Here's how you do it using the cognizant administration utility:

$ cognizant load ./examples/redis-server.rb

Assuming that the loaded redis-server.rb file contains:

Cognizant.application("redis-example") do |app|
  # app.pids_dir = "~/.cognizant/redis-example/pids/"
  # app.logs_dir = "~/.cognizant/redis-example/logs/"

  app.monitor("redis-server-6666") do |process|
    process.autostart = true
    process.group = "redis"
    # process.uid = "redis"
    # process.gid = "redis"
    process.start_command = "redis-server -"
    process.start_with_input = <<-heredoc
      daemonize no
      port 6666
    heredoc
    process.ping_command  = "redis-cli -p 6666 PING"
  end
end

For detailed usage examples, see the examples section.