invoker
invoker copied to clipboard
Support for groups
I've tried adding support for groups. Here's an example invoker.ini
[memcached]
command = /usr/local/opt/memcached/bin/memcached
disable_autorun = true
group = db
[postgres]
command = /usr/local/Cellar/postgresql/9.3.5_1/bin/postgres -D /usr/local/var/postgres
group = db
disable_autorun = true
stop_signal = TERM
[redis]
command = redis-server /usr/local/etc/redis.conf
disable_autorun = true
group = db
To start all processes of db group, run
invoker add db
To stop all processes of db group, run
invoker remove db
To restart all process of db group, run
invoker reload db
The pull handles groups at the ipc command level. I haven't any touched start/stop/restart code. When trying to test this feature, I ran into an issue where invoker wasn't tracking processes correctly. Here's an example where grep says memcached is no longer running, however invoker shows a pid of 4315
~/code/invoker (groups)% bin/invoker add db
~/code/invoker (groups)% bin/invoker list
+-----+------+--------------+---------------------------------------------+
| dir | pid | process_name | shell_command |
+-----+------+--------------+---------------------------------------------+
| | 4315 | memcached | /usr/local/opt/memcached/bin/memcached |
| | 4316 | postgres | /usr/local/Cellar/postgresql/9.3.5_1/bin/.. |
| | 4317 | redis | redis-server /usr/local/etc/redis.conf |
+-----+------+--------------+---------------------------------------------+
~/code/invoker (groups)% ps -ef | grep 'memcached\|postgres\|redis'
502 4319 4316 0 1:54AM ?? 0:00.00 postgres: checkpointer process
502 4320 4316 0 1:54AM ?? 0:00.00 postgres: writer process
502 4321 4316 0 1:54AM ?? 0:00.00 postgres: wal writer process
502 4322 4316 0 1:54AM ?? 0:00.00 postgres: autovacuum launcher process
502 4323 4316 0 1:54AM ?? 0:00.00 postgres: stats collector process
502 4315 4179 0 1:54AM ttys000 0:00.01 /usr/local/opt/memcached/bin/memcached
502 4316 4179 0 1:54AM ttys000 0:00.05 /usr/local/Cellar/postgresql/9.3.5_1/bin/postgres -D /usr/local/var/postgres
502 4317 4179 0 1:54AM ttys000 0:00.03 redis-server 127.0.0.1:6379
502 4342 4184 0 1:54AM ttys002 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn memcached\|postgres\|redis
~/code/invoker (groups)% bin/invoker remove db
~/code/invoker (groups)% bin/invoker list
+-----+-------------+--------------+---------------------------------------------+
| dir | pid | process_name | shell_command |
+-----+-------------+--------------+---------------------------------------------+
| | 4315 | memcached | /usr/local/opt/memcached/bin/memcached |
| | Not Running | postgres | /usr/local/Cellar/postgresql/9.3.5_1/bin/.. |
| | Not Running | redis | redis-server /usr/local/etc/redis.conf |
+-----+-------------+--------------+---------------------------------------------+
~/code/invoker (groups)% ps -ef | grep 'memcached\|postgres\|redis'
502 4394 4184 0 1:55AM ttys002 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn memcached\|postgres\|redis
~/code/invoker (groups)%
~/code/invoker (groups)% bin/invoker start invoker.ini
You can enable OSX notification for processes by installing terminal-notifier gem
redis : 4317:M 19 Jun 01:54:44.265 * Increased maximum number of open files to 10032 (it was originally set to 4864).
redis : _._
redis : _.-``__ ''-._
redis : _.-`` `. `_. ''-._ Redis 3.0.0 (00000000/0) 64 bit
redis : .-`` .-```. ```\/ _.,_ ''-._
redis : ( ' , .-` | `, ) Running in standalone mode
redis : |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
redis : | `-._ `._ / _.-' | PID: 4317
redis : `-._ `-._ `-./ _.-' _.-'
redis : |`-._`-._ `-.__.-' _.-'_.-'|
redis : | `-._`-._ _.-'_.-' | http://redis.io
redis : `-._ `-._`-.__.-'_.-' _.-'
redis : |`-._`-._ `-.__.-' _.-'_.-'|
redis : | `-._`-._ _.-'_.-' |
redis : `-._ `-._`-.__.-'_.-' _.-'
redis : `-._ `-.__.-' _.-'
redis : `-._ _.-'
redis : `-.__.-'
redis :
redis : 4317:M 19 Jun 01:54:44.272 # Server started, Redis version 3.0.0
redis : 4317:M 19 Jun 01:54:44.286 * DB loaded from disk: 0.013 seconds
redis : 4317:M 19 Jun 01:54:44.286 * The server is now ready to accept connections on port 6379
postgres : LOG: database system was shut down at 2015-06-19 00:23:13 IST
postgres : LOG: database system is ready to accept connections
postgres : LOG: autovacuum launcher started
Removing memcached with signal INT
Removing postgres with signal TERM
Removing redis with signal INT
memcached : Signal handled: Interrupt: 2.
Process with command memcached exited with status 0
postgres : LOG: received smart shutdown request
postgres : LOG: autovacuum launcher shutting down
postgres : LOG: shutting down
postgres : LOG: database system is shut down
redis : 4317:signal-handler (1434659104) Received SIGINT scheduling shutdown...
redis : 4317:M 19 Jun 01:55:04.236 # User requested shutdown...
redis : 4317:M 19 Jun 01:55:04.236 * Saving the final RDB snapshot before exiting.
redis : 4317:M 19 Jun 01:55:04.251 * DB saved on disk
redis : 4317:M 19 Jun 01:55:04.251 # Redis is now ready to exit, bye bye...
Process with command postgres exited with status 0
Process with command redis exited with status 0
I've tried debugging but couldn't figure out why this was happening. Opening a WIP pull so someone else can try replicating this issue on their machines. @iffyuva Thoughts?
@nisanth074 will look into this when i find time. thanks.
@nisanth074 please rebase this PR. thanks.
@iffyuva Done