Giter Club home page Giter Club logo

cognizant's Introduction

Cognizant

Simple and reliable process monitoring framework written in Ruby

Gem Version Dependency Status Code Climate Build Status Coverage Status

Quick start

Install Cognizant
$ gem install cognizant
Example thin server cluster configuration
$ vim thin_cluster.cz
app_root = "/apps/acmecorp.com"
servers = 5
port = 4000

Cognizant.application "acmecorp.com" do |app|
  servers.times do |n|
    app.monitor "thin-#{n}" do
      autostart!      
      group "thin"
      uid "www-data"
      gid "www-data"

      env RACK_ENV: "production"
      chdir "#{app_root}/current"

      daemonize false
      pidfile "#{app_root}/shared/tmp/pids/thin.400#{n}.pid"

      start_command   "bundle exec thin start   --only #{n} --servers #{servers} --port #{port}"
      stop_command    "bundle exec thin stop    --only #{n} --servers #{servers} --port #{port}"
      restart_command "bundle exec thin restart --only #{n} --servers #{servers} --port #{port}"

	  check :flapping, times: 3, within: 1.minute, retry_after: 15.seconds, retries: 10
      check :transition, from: :running, to: :stopped do |process|
        `say a thin server has stopped` # send an email, etc.
      end

      check :cpu_usage,    above: 50.percent,    every: 5.seconds, times: 5,      do: :restart
      check :memory_usage, above: 300.megabytes, every: 5.seconds, times: [3, 5], do: :restart
    end
  end
end

YAML version of this example is available in the wiki.

Start the daemon and load the configuration
$ cognizantd
$ cognizant load thin_cluster.cz
Enter the Cognizant shell and view the status of managed processes
$ cognizant
Welcome Gurpartap! You are speaking to the Cognizant Monitoring Daemon.
Enter 'help' if you're not sure what to do.

Type 'quit' or 'exit' to quit at any time.
> use acmecorp.com
OK
(acmecorp.com)> status
+---------+-------+------------------------+-------+-------+--------+
| Process | Group | State                  | PID   | % CPU | Memory |
+---------+-------+------------------------+-------+-------+--------+
| thin-0  | thin  | running since 1 minute | 59825 | 0.0   | 47 MiB |
+---------+-------+------------------------+-------+-------+--------+
| thin-1  | thin  | running since 1 minute | 59828 | 0.0   | 47 MiB |
+---------+-------+------------------------+-------+-------+--------+
| thin-2  | thin  | running since 1 minute | 59829 | 0.0   | 47 MiB |
+---------+-------+------------------------+-------+-------+--------+
2013-03-18 10:00:29 +0530

Further information

Cognizant has an extensively documented wiki for that.

About

Cognizant is a project of Gurpartap Singh. Feel free to get in touch.

cognizant's People

Contributors

gurpartap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.