Code Monkey home page Code Monkey logo

mongroup's Introduction

mongroup

mongroup is a wrapper for mon. It allows you to create easily monitor a group of processes.

##Installation

make install

One-liner:

(mkdir /tmp/mongroup && cd /tmp/mongroup && curl -L# https://github.com/jgallen23/mongroup/archive/master.tar.gz | tar zx --strip 1 && make install)

Usage

Usage: mongroup [options] [command]

Options:

	-c, --config <path>  set config path. defaults to ./mongroup.conf
	-V, --version        output program version
	-h, --help           output help information

Commands:

	start [app]          start [app] or all apps
	restart [app]        restart [app] or all apps
	stop [app]           stops [app] or all apps
	status               shows the status of all running apps
	log [app]            tail the [app]'s log or all apps
	logf [app]           tail -f the [app]'s log or all apps
	update               update mongroup to the latest version

Config File

A config file lets you define what process you want to run in your mongroup. It also lets you set the directories for where your pids and logs are stored. Here is an example config file:

	pids = /var/run/
	logs = /var/log/
	on-error = ./alert error
	on-restart = ./alert restart
	web = node server 8001
	web2 = node server 8002
	redis = redis-server

Failure Hooks

Mongroup leverages mon(1)'s --on-error <cmd> and --on-restart <cmd> flags to facilitate reporting and alerting. For example here's a simple non-useful node script outputting to stdio:

#!/usr/bin/env node

console.log(process.argv);

/*

example:

[ 'node',
  '/Users/tj/projects/mongroup/example/alert.js',
  'restart',
  'web2',
  '58119' ]

*/

mongroup's People

Contributors

adam12 avatar jgallen23 avatar matthewmueller avatar tj avatar weisjohn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongroup's Issues

Not able to control the process in the example using mongroup

I used the default example to perform following action

cd example

Edited mongroup.conf file to provide pid and log directory

Started the mongroup inside example folder
mongroup start >> All 5 instances launched
mongroup stop >> All 5 instances stopped.

mongroup restart >> All 5 instances restarted.

Now i kill web2 instance using : ps -ef , kill PID_FOUND
Here mongroup try to restart the process but couldn't
Here is the web2.log file output

---====================
Error: listen EADDRINUSE
at errnoException (net.js:646:11)
at Array.0 (net.js:747:26)
at EventEmitter._tickCallback (node.js:192:41)
[ 'node',
'/home/vagrant/mongroup/example/alert.js',
'restart',
'web2',
'27120' ]
Server running at http://127.0.0.1:8002/

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: listen EADDRINUSE
at errnoException (net.js:646:11)
at Array.0 (net.js:747:26)
at EventEmitter._tickCallback (node.js:192:41)
[ 'node',
'/home/vagrant/mongroup/example/alert.js',
'restart',
'web2',
'27154' ]
Server running at http://127.0.0.1:8002/

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: listen EADDRINUSE
at errnoException (net.js:646:11)
at Array.0 (net.js:747:26)
at EventEmitter._tickCallback (node.js:192:41)
root@vagrant-ubuntu-precise-64:/home/vagrant/mongroup/example#

--=====================

After 4 tries mongroup failed to start this process. If mongroup not restarting process then how come web2 is still online and why mongroup looses track of this process? mongroup stop/start looses control over this process.
Kindly pardon my ignorance and help me debug this.

signals not getting passed through

have some cleanup work to do on my process (a server), but when I issue a kill -s SIGQUIT $pid it will kill the process, but it doesn't run the cleanup.

I've noticed this will work fine with mon.

when specifying the config file location, the default `status` command doesn't work

First command works, second doesn't.

$ ./bin/mongroup -c example/mongroup.conf status

         web : dead
        web2 : dead
        web3 : dead
        web4 : dead
        web5 : dead

$ ./bin/mongroup -c example/mongroup.conf
$

This may seem like a trivial issue but I wanted to just alias mg to mg -c ~/conf/mongroup.con, therefore being able to mg to get the status and still use mg stop or mg start, etc. etc.

wait for child processes to die before restarting

removes the need for the arbitrary sleep. We're using SIGQUIT for graceful shutdowns so:

  • mongroup should allow a hard restart with SIGTERM
  • mongroup should wait for child processes to die

stuff like that is pretty annoying in shelll scripts, might look into rewriting mongroup in C soon if we have time

Mongroup and the --on-error flag.

It seems to me that one of the benefits of mon is that you can get an alert when something dies.

I've just quickly browsed through the README and code and I can't seem to see how you can do that using mongroup.

Am I missing something or can't you specify the --on-error flag for mon's mongroup start up?

restart doesn't restart processes

Hello,

I've been testing mongroup locally on my OSX 10.8 box before deploying this to production and encountered a minor issue with restart.

I have this basic config:

pids = tmp/pids
logs = log
worker = rake resque:work QUEUE=main,ts_delta
apn = rake apn:sender QUEUE=apple_push_notifications

When started with mongroup, everything is ok:

$ mongroup -c config/mongroup.conf status

      worker : 4093 : alive : uptime 7 seconds
         apn : 4096 : alive : uptime 7 seconds

But when done a restart

$ mongroup -c config/mongroup.conf restart

        stop : worker
        stop : apn
     running : worker
     running : apn

The child processes are terminated and never get up again, so status reports them dead:

$ mongroup -c config/mongroup.conf status

      worker : 4093 : dead
         apn : 4096 : dead

And using ps to verify I confirm they are dead ๐Ÿ‘…

Last time I checked resque did work properly for this (used with foreman and Procfiles) so I think it respond properly to process termination signals.

Thank you for creating this tool! โค๏ธ โค๏ธ โค๏ธ

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.