-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe94e85
commit a3ecc8e
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
incrproc, | ||
list, | ||
listen, | ||
listpids, | ||
numprocesses, | ||
numwatchers, | ||
options, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from circus.commands.base import Command | ||
from circus.exc import ArgumentError | ||
|
||
|
||
class ListPids(Command): | ||
"""\ | ||
Get list of pids in a watcher | ||
============================= | ||
ZMQ Message | ||
----------- | ||
To get the list of pid in a watcher:: | ||
{ | ||
"command": "listpids", | ||
"properties": { | ||
"name": "nameofwatcher", | ||
} | ||
} | ||
The response return the list asked. | ||
Command line | ||
------------ | ||
:: | ||
$ circusctl listpids <name> | ||
""" | ||
name = "listpids" | ||
|
||
def message(self, *args, **opts): | ||
if len(args) != 1: | ||
raise ArgumentError("invalid number of arguments") | ||
|
||
return self.make_message(name=args[0]) | ||
|
||
def execute(self, arbiter, props): | ||
watcher = self._get_watcher(arbiter, props['name']) | ||
pids = [process.pid for process in watcher.processes.values()] | ||
pids.sort() | ||
return {"pids": pids} | ||
|
||
def console_msg(self, msg): | ||
if 'pids' in msg: | ||
return ",".join([str(pid) for pid in msg.get('pids')]) | ||
return self.console_error(msg) |