From 7c3a5460e1dca92cb857107b9e8b9b68c6d239b4 Mon Sep 17 00:00:00 2001 From: Nickolay Sokolov Date: Mon, 4 Jul 2011 21:03:01 +0400 Subject: [PATCH 1/7] Gracefull shutdown of nova-api. --- bin/nova-api | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/nova-api b/bin/nova-api index fff67251..71c68f24 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -24,6 +24,7 @@ Starts both the EC2 and OpenStack APIs in separate processes. """ import os +import signal import sys possible_topdir = os.path.normpath(os.path.join(os.path.abspath( @@ -34,11 +35,15 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils +def create_kill_handler(launcher): + def handle(signal, frame): + launcher.stop() + return handle def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) - + ec2 = nova.service.WSGIService("ec2") osapi = nova.service.WSGIService("osapi") @@ -46,10 +51,9 @@ def main(): launcher.launch_service(ec2) launcher.launch_service(osapi) - try: - launcher.wait() - except KeyboardInterrupt: - launcher.stop() + signal.signal(signal.SIGTERM, create_kill_handler(launcher)) + + launcher.wait() if __name__ == '__main__': From 66ac43e54eea65b68d545279070e0fd4eecd4743 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Mon, 4 Jul 2011 23:48:05 +0400 Subject: [PATCH 2/7] Gracefull shutdown of nova-api. --- Authors | 1 + bin/nova-api | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Authors b/Authors index c3a65f1b..f2770852 100644 --- a/Authors +++ b/Authors @@ -93,3 +93,4 @@ Yoshiaki Tamura Youcef Laribi Yuriy Taraday Zhixue Wu +Nikolay Sokolov diff --git a/bin/nova-api b/bin/nova-api index fff67251..71c68f24 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -24,6 +24,7 @@ Starts both the EC2 and OpenStack APIs in separate processes. """ import os +import signal import sys possible_topdir = os.path.normpath(os.path.join(os.path.abspath( @@ -34,11 +35,15 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils +def create_kill_handler(launcher): + def handle(signal, frame): + launcher.stop() + return handle def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) - + ec2 = nova.service.WSGIService("ec2") osapi = nova.service.WSGIService("osapi") @@ -46,10 +51,9 @@ def main(): launcher.launch_service(ec2) launcher.launch_service(osapi) - try: - launcher.wait() - except KeyboardInterrupt: - launcher.stop() + signal.signal(signal.SIGTERM, create_kill_handler(launcher)) + + launcher.wait() if __name__ == '__main__': From 2f18773a9426ff0c9edd0a60f1e78cdf50769121 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 00:24:55 +0400 Subject: [PATCH 3/7] Signal handler cleanup, proper ^C handling. --- bin/nova-api | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bin/nova-api b/bin/nova-api index 71c68f24..a51eb1b6 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -35,11 +35,6 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils -def create_kill_handler(launcher): - def handle(signal, frame): - launcher.stop() - return handle - def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) @@ -51,9 +46,12 @@ def main(): launcher.launch_service(ec2) launcher.launch_service(osapi) - signal.signal(signal.SIGTERM, create_kill_handler(launcher)) - - launcher.wait() + signal.signal(signal.SIGTERM, lambda *_: launcher.stop()) + + try: + launcher.wait() + except KeyboardInterrupt: + launcher.stop() if __name__ == '__main__': From 958fc7add6f99acbb309d2fc363d723bf6c9f5b9 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 00:43:39 +0400 Subject: [PATCH 4/7] Proper Author section insertion (thx Eldar). --- Authors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Authors b/Authors index f2770852..1b3c9076 100644 --- a/Authors +++ b/Authors @@ -68,6 +68,7 @@ MORITA Kazutaka Muneyuki Noguchi Nachi Ueno Naveed Massjouni +Nikolay Sokolov Nirmal Ranganathan Paul Voccio Renuka Apte @@ -93,4 +94,3 @@ Yoshiaki Tamura Youcef Laribi Yuriy Taraday Zhixue Wu -Nikolay Sokolov From 9e34d7ca2ea16bc8554f6076ef653209b5fd5dc5 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 01:09:00 +0400 Subject: [PATCH 5/7] Formatting fix. --- bin/nova-api | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/nova-api b/bin/nova-api index a51eb1b6..ccbb103f 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -27,6 +27,7 @@ import os import signal import sys + possible_topdir = os.path.normpath(os.path.join(os.path.abspath( sys.argv[0]), os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): From 767cbfb24cff8dc4be8e6626f5a001b0384d6b8a Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 01:31:04 +0400 Subject: [PATCH 6/7] PEP8 passed. --- bin/nova-api | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/nova-api b/bin/nova-api index ccbb103f..4c5164ea 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -36,10 +36,11 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils + def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) - + ec2 = nova.service.WSGIService("ec2") osapi = nova.service.WSGIService("osapi") @@ -48,7 +49,7 @@ def main(): launcher.launch_service(osapi) signal.signal(signal.SIGTERM, lambda *_: launcher.stop()) - + try: launcher.wait() except KeyboardInterrupt: From a6d3ea408ca2743c0a742444925fff07ae4019ba Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Fri, 8 Jul 2011 12:37:56 +0400 Subject: [PATCH 7/7] Updated mailmap due to wrong address in commit message. --- .mailmap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 6673d0a2..ff304c89 100644 --- a/.mailmap +++ b/.mailmap @@ -50,4 +50,5 @@ - \ No newline at end of file + +