Code Monkey home page Code Monkey logo

passenger-monitor's Introduction

PassengerMonitor

Code Climate

This gem monitors passenger workers of your application and if the workers exceed the memory limit then it kills them (first gracefully, waits and then forcefully). It fetches the memory of the passenger workers from the system command passenger-memory-stats, checks the memory of each worker concurrently (using threads) and kills them if it finds them bloated. First, it kills the process gracefully and wait for it to die, if the process still appears then it kills it forcefully

Installation

Add this line to your application's Gemfile:

gem 'passenger-monitor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install passenger-monitor

Usage

The gem provides a service class which can be initialized to check the passenger workers.

PassengerMonitor.run({:memory_limit=>"150",
                      :log_file=>"passenger_config.log",
                      :wait_time=>"15",
                      :process_name_regex=>"passenger"})

Parameters options:

  1. :memory_limit: allowed memory limit for a passenger worker
  2. :log_file: the name of the log file
  3. :wait_time: the time to wait to kill the worker forcefully
  4. :process_name_regex: regex for the passenger worker of the application

Use Rake task

It also provides a rake task which can be scheduled in cron tasks. To load tasks add following lines in your Rakefile:

spec = Gem::Specification.find_by_name 'passenger_monitor'
Dir.glob("#{spec.gem_dir}/lib/tasks/*.rake").each { |task_file| load task_file }

Now rake task passenger:monitor will be available. For custom configuration, send arguments in task in following order: :memory_limit, :log_file, :wait_time, :process_name_regex:

bundle exec rake passenger:monitor[150,"passenger_config.log",15,"Passenger RubyApp"]

That's it, now never think of bloated passengers.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/passenger-monitor/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Credits

vinsol.com: Ruby on Rails, iOS and Android developers

Copyright (c) 2014 vinsol.com, released under the New MIT License

passenger-monitor's People

Contributors

akshay-vishnoi avatar jitendra avatar

Watchers

Akhil Bansal avatar Satish Kr Chauhan avatar James Cloos 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.