• Stars
    star
    1,187
  • Rank 37,838 (Top 0.8 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Process monitoring tool. Inspired from Bluepill and God.

Eye

Gem Version Build Status Coverage Status

Process monitoring tool. Inspired from Bluepill and God. Requires Ruby(MRI) >= 1.9.3-p194. Uses Celluloid and Celluloid::IO.

Little demo, shows general commands and how chain works:

Eye

Installation:

$ gem install eye

Why?

We have used god and bluepill in production and always ran into bugs (segfaults, crashes, lost processes, kill not-related processes, load problems, deploy problems, ...)

We wanted something more robust and production stable.

We wanted the features of bluepill and god, with a few extras like chains, nested configuring, mask matching, easy debug configs

I hope we've succeeded, we're using eye in production and are quite happy.

Config example

examples/test.eye (more examples)

# load submodules, here just for example
Eye.load('./eye/*.rb')

# Eye self-configuration section
Eye.config do
  logger '/tmp/eye.log'
end

# Adding application
Eye.application 'test' do
  # All options inherits down to the config leafs.
  # except `env`, which merging down

  # uid "user_name" # run app as a user_name (optional) - available only on ruby >= 2.0
  # gid "group_name" # run app as a group_name (optional) - available only on ruby >= 2.0

  working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))
  stdall 'trash.log' # stdout,err logs for processes by default
  env 'APP_ENV' => 'production' # global env for each processes
  trigger :flapping, times: 10, within: 1.minute, retry_in: 10.minutes
  check :cpu, every: 10.seconds, below: 100, times: 3 # global check for all processes

  group 'samples' do
    chain grace: 5.seconds # chained start-restart with 5s interval, one by one.

    # eye daemonized process
    process :sample1 do
      pid_file '1.pid' # pid_path will be expanded with the working_dir
      start_command 'ruby ./sample.rb'

      # when no stop_command or stop_signals, default stop is [:TERM, 0.5, :KILL]
      # default `restart` command is `stop; start`

      daemonize true
      stdall 'sample1.log'

      # ensure the CPU is below 30% at least 3 out of the last 5 times checked
      check :cpu, below: 30, times: [3, 5]
    end

    # self daemonized process
    process :sample2 do
      pid_file '2.pid'
      start_command 'ruby ./sample.rb -d --pid 2.pid --log sample2.log'
      stop_command 'kill -9 {PID}'

      # ensure the memory is below 300Mb the last 3 times checked
      check :memory, every: 20.seconds, below: 300.megabytes, times: 3
    end
  end

  # daemon with 3 children
  process :forking do
    pid_file 'forking.pid'
    start_command 'ruby ./forking.rb start'
    stop_command 'ruby forking.rb stop'
    stdall 'forking.log'

    start_timeout 10.seconds
    stop_timeout 5.seconds

    monitor_children do
      restart_command 'kill -2 {PID}' # for this child process
      check :memory, below: 300.megabytes, times: 3
    end
  end

  # eventmachine process, daemonized with eye
  process :event_machine do
    pid_file 'em.pid'
    start_command 'ruby em.rb'
    stdout 'em.log'
    daemonize true
    stop_signals [:QUIT, 2.seconds, :KILL]

    check :socket, addr: 'tcp://127.0.0.1:33221', every: 10.seconds, times: 2,
                   timeout: 1.second, send_data: 'ping', expect_data: /pong/
  end

  # thin process, self daemonized
  process :thin do
    pid_file 'thin.pid'
    start_command 'bundle exec thin start -R thin.ru -p 33233 -d -l thin.log -P thin.pid'
    stop_signals [:QUIT, 2.seconds, :TERM, 1.seconds, :KILL]

    check :http, url: 'http://127.0.0.1:33233/hello', pattern: /World/,
                 every: 5.seconds, times: [2, 3], timeout: 1.second
  end
end

Start eye daemon and/or load config:

$ eye l(oad) examples/test.eye

load folder with configs:

$ eye l examples/
$ eye l examples/*.rb

foreground load:

$ eye l CONF -f

If the eye daemon has already started and you call the load command, the config will be updated (into eye daemon). New objects(applications, groups, processes) will be added and monitored. Processes removed from the config will be removed (and stopped if the process has stop_on_delete true). Other objects will update their configs.

Two global configs loaded by default, if they exist (with the first eye load):

/etc/eye.conf
~/.eyeconfig

Process statuses:

$ eye i(nfo)
test
  samples
    sample1 ....................... up  (21:52, 0%, 13Mb, <4107>)
    sample2 ....................... up  (21:52, 0%, 12Mb, <4142>)
  event_machine ................... up  (21:52, 3%, 26Mb, <4112>)
  forking ......................... up  (21:52, 0%, 41Mb, <4203>)
    child-4206 .................... up  (21:52, 0%, 41Mb, <4206>)
    child-4211 .................... up  (21:52, 0%, 41Mb, <4211>)
    child-4214 .................... up  (21:52, 0%, 41Mb, <4214>)
  thin ............................ up  (21:53, 2%, 54Mb, <4228>)
$ eye i -j # show info in JSON format

Commands:

start, stop, restart, delete, monitor, unmonitor

Command params (with restart for example):

$ eye r(estart) all
$ eye r test
$ eye r samples
$ eye r sample1
$ eye r sample*
$ eye r test:samples
$ eye r test:samples:sample1
$ eye r test:samples:sample*
$ eye r test:*sample*

Check config syntax:

$ eye c(heck) examples/test.eye

Config explain (for debug):

$ eye e(xplain) examples/test.eye

Log tracing (tail and grep):

$ eye t(race)
$ eye t test
$ eye t sample

Quit monitoring:

$ eye q(uit)
$ eye q -s # stop all processes and quit

Interactive info:

$ eye w(atch)

Process statuses history:

$ eye hi(story)

Eye daemon info:

$ eye x(info)
$ eye x -c # for show current config

Local Eye version LEye (like foreman):

LEye

Process states and events:

Eye

How to write Eye extensions, plugins, gems:

Eye-http Eye-rotate Eye-hipchat Plugin example

Eye related projects

Articles

Wiki

Thanks Bluepill for the nice config ideas.

More Repositories

1

benchmarks

Some benchmarks of different languages
Makefile
2,738
star
2

myhtml

Fast HTML5 Parser with css selectors for Crystal language
Crystal
151
star
3

crystal-benchmarks-game

Crystal implementations for The Computer Language Benchmarks Game
C
114
star
4

jit-benchmarks

Benchmark for interpreted languages implementations.
Ruby
94
star
5

lexbor

Fast HTML5 Parser with CSS selectors. This is successor of myhtml and expected to be faster and use less memory.
Crystal
88
star
6

simple_rpc

RPC Server and Client for Crystal. Implements msgpack-rpc protocol.
Crystal
63
star
7

modest

CSS selectors for HTML5 Parser myhtml
Crystal
48
star
8

cron_scheduler

Simple job scheduler with crontab patterns for Crystal Language.
Crystal
46
star
9

limiter

Rate limiter for Crystal. Memory and Redis based.
Crystal
34
star
10

pg_csv

Fast Ruby PG csv export. Uses pg function 'copy to csv'. Effective on millions rows.
Ruby
30
star
11

memory_cache

Super simple in memory key-value storage with expires for Crystal.
Crystal
29
star
12

pg_reindex

Console utility for gracefully rebuild indexes/pkeys for PostgreSQL, with minimal locking in semi-auto mode.
Ruby
20
star
13

auto_json

Auto JSON convertations for classes and structs, based on auto_constructor fields
Crystal
19
star
14

run_with_fork

Some simple parallelism for Crystal. Run some heavy or blocked thread operations in background fork.
Crystal
19
star
15

redisoid

Redis client for Crystal with auto-reconnection and pool (wrapper for stefanwille/crystal-redis, kostya/redis-reconnect, ysbaddaden/pool). Ready to use in production.
Crystal
17
star
16

http_parser.cr

Crystal wrapper for Http Parser lib: https://github.com/joyent/http-parser
C
16
star
17

auto_initialize

Generate initialize methods for classes and structs
Crystal
15
star
18

pgq

Queues system for AR/Rails based on PgQ Skytools for PostgreSQL, like Resque on Redis. Rails 2.3 and 3 compatible.
Ruby
12
star
19

ruby-app

Ruby micro framework for easy create ruby applications (daemons, EventMachine-apps, db-apps, cli...). Features: bundler, environments, activesupport, rails dirs tree. Fast loading and low memory using.
Ruby
11
star
20

cron_parser

Cron parser for Crystal language. Translated from Ruby https://github.com/siebertm/parse-cron
Crystal
11
star
21

eye-http

Http interface for the Eye gem
Ruby
10
star
22

curl-downloader

Powerfull http-client for Crystal based on libcurl binding.
Crystal
9
star
23

eye-rotate

Log rotate for the Eye gem.
Ruby
8
star
24

balancer

Simple Tcp Balancer
Crystal
8
star
25

socks

Socks5 server in Crystal. Simple implementation without auth, bind, associate and ipv6.
Crystal
8
star
26

simple_idn

SimpleIdn for Crystal language. Translated from Ruby https://github.com/mmriis/simpleidn
Crystal
7
star
27

auto_constructor

Auto construct initialize methods for classes and structs
Crystal
7
star
28

confuddle

Utility for work with unfuddle.com account from console
Ruby
7
star
29

redis-reconnect

Redis client with autoreconnection for slow clients (wrapper for stefanwille/crystal-redis). Used as part of redisoid shard.
Crystal
7
star
30

tkrzw

Fast Persistent Key Value Storage
Crystal
6
star
31

timeouter

Simple timeouter
Crystal
6
star
32

blank

method Blank for Crystal Language
Crystal
6
star
33

bin_script

Easy writing and executing bins(executable scripts) in Rails Application (especially for crontab or god). For my purposes much better than Rake, Thor and Rails Runner.
Ruby
6
star
34

nagios_helper

Gem for writing, testing, executing Nagios checks inside Rails application. Checks running throught http or script.
Ruby
6
star
35

kyotocabinet

Fast Persistent Embedded KeyValue Storage. Wrapper for KyotoCabinet
Crystal
5
star
36

sidekiq-kawai

Syntax sugar for Sidekiq consumers. Each consumer is a class, with clean interface, and custom logger.
Ruby
5
star
37

jaro_winkler

Crystal implementation of Jaro-Winkler distance algorithm which supports UTF-8 string
Crystal
5
star
38

public_suffix

Public Suffix for Crystal
Crystal
4
star
39

entities

Crystal html entities decoder
Crystal
4
star
40

stuffs

Some stuffs which i used in every project for Crystal. Mini ActiveSupport
Crystal
3
star
41

forking

Simple processes forking, and restarting. Master process starts as daemon.
Ruby
3
star
42

thread_pool

Simple Thread pool for Crystal
Crystal
3
star
43

fast_to_f

Fast floats parser in Crystal (wrapper for fast_double_parser).
Crystal
3
star
44

idn_ffi

LibIdn FFI ruby binding
Ruby
3
star
45

pgq_web

Web interface for pgq gem. Inspect pgq and londiste queues
Ruby
3
star
46

encoding_name

Normalizer of encoding name for Crystal (to use it in crystal internal encoder-decoder)
Crystal
3
star
47

resque-kawai

Syntax sugar for Resque consumers. Each consumer is a class, with clean interface, and custom logger.
Ruby
3
star
48

to_query

ActiveSupport to_query method for Crystal.
Crystal
2
star
49

find_lib

Find dynamic libary in system paths, multiplatform (to use dlopen and dlsym).
Crystal
2
star
50

html_unicoder

Convert html page to utf-8 for Crystal language
Crystal
2
star
51

msgpack_protocol

Msgpack protocol for eventmachine
Ruby
2
star
52

encoding-kawai

EncodingKawai - little sintax sugar for ruby force_encoding, also working on 1.8.7.
Ruby
2
star
53

marshal64

Marshal + Base64 coder. Usefull for serialize data to db.
Ruby
1
star
54

sidekiq-marshal

Marshal encoder for sidekiq. Enables when required.
Ruby
1
star
55

jober

Simple background jobs, queues.
Ruby
1
star
56

resque-marshal

Marshal encoder for resque. Enables when required.
Ruby
1
star
57

crystal-metric

This is set of 21 benchmarks for Crystal language, as one file.
Crystal
1
star
58

em-nodes

Simple abstraction on top of EventMachine for easy create clients, servers, workers, ...
Ruby
1
star
59

ruby-app-cron

RubyApp extension, adds Forverb support.
Ruby
1
star
60

nagios_rails_server

Async server for gem nagios_helper, based on rack,thin and async-sinatra.
Ruby
1
star
61

nagios_check

Dsl to create nagios checks, inside application.
Crystal
1
star
62

pg_reconnect

ActiveRecord PostgreSQL auto-reconnection, works with 2.3 and 3.2 rails. Uses hackety wrapper on adapter execute.
Ruby
1
star
63

ruby-app-ar

RubyApp extension, adds ActiveRecord support.
Ruby
1
star