From 1916600d5c12043f00362ab3da54d0ef83c8ea3c Mon Sep 17 00:00:00 2001 From: Sathish Nagappan Date: Thu, 11 Oct 2012 20:45:46 -0700 Subject: [PATCH] add command "status" to "glance-control" fixes Bug #955457 The status command displays whether or not a service is running. Change-Id: Ib4be08a182465d94f33d6ec64d0c089ddc411e3f --- bin/glance-control | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/glance-control b/bin/glance-control index 3355797b..606478bd 100755 --- a/bin/glance-control +++ b/bin/glance-control @@ -49,7 +49,7 @@ from glance.openstack.common import cfg CONF = cfg.CONF -ALL_COMMANDS = ['start', 'stop', 'shutdown', 'restart', +ALL_COMMANDS = ['start', 'status', 'stop', 'shutdown', 'restart', 'reload', 'force-reload'] ALL_SERVERS = ['glance-api', 'glance-registry', 'glance-scrubber'] GRACEFUL_SHUTDOWN_SERVERS = ['glance-api', 'glance-registry', @@ -197,6 +197,14 @@ def do_start(verb, pid_file, server, args): return launch(pid_file, conf_file, CONF.capture_output, CONF.await_child) +def do_check_status(pid_file, server): + if os.path.exists(pid_file): + pid = open(pid_file).read().strip() + print "%s running: %s" % (server, pid) + else: + print "No %s running" % server + + def get_pid_file(pid, pid_file): pid_file = (os.path.abspath(pid_file) if pid_file else '/var/run/glance/%s.pid' % server) @@ -338,6 +346,11 @@ if __name__ == '__main__': anticipate_respawn(children) + if command == 'status': + for server in servers: + pid_file = get_pid_file(server, CONF.pid_file) + do_check_status(pid_file, server) + if command == 'stop': for server in servers: do_stop(server, args)