Skip to content

status: Add --sort=start and --reverse options #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions supervisor/supervisorctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import cmd
import sys
import getpass

import operator
import socket
import errno
import threading
Expand Down Expand Up @@ -612,8 +612,19 @@ def do_status(self, arg):

supervisor = self.ctl.get_supervisor()
all_infos = supervisor.getAllProcessInfo()
sort_by_starttime = False
reverse = False

names = arg.split()
args = arg.split()

options = [arg for arg in args if arg.startswith('--')]
for option in options:
if option.startswith('--sort=start'):
sort_by_starttime = True
if option.startswith('--reverse'):
reverse = True

names = [arg for arg in args if not arg.startswith('--')]
if not names or "all" in names:
matching_infos = all_infos
else:
Expand All @@ -638,6 +649,9 @@ def do_status(self, arg):
else:
msg = "%s: ERROR (no such process)" % name
self.ctl.output(msg)
if sort_by_starttime:
matching_infos.sort(key=operator.itemgetter('start'),
reverse=reverse)
self._show_statuses(matching_infos)

def help_status(self):
Expand Down