diff options
| author | Nikolay Sokolov <nsokolov@griddynamics.com> | 2011-07-04 23:48:05 +0400 |
|---|---|---|
| committer | Nikolay Sokolov <nsokolov@griddynamics.com> | 2011-07-04 23:48:05 +0400 |
| commit | 1732c373aa21fb7493b8fb50dd64bdf9425bf70b (patch) | |
| tree | 8e8b02fc8fb7800929c50a955464d989f3ec18d6 /bin/nova-api | |
| parent | 6843421be9cdef1fc12d3480889bdcfd96821e1b (diff) | |
| download | nova-1732c373aa21fb7493b8fb50dd64bdf9425bf70b.tar.gz nova-1732c373aa21fb7493b8fb50dd64bdf9425bf70b.tar.xz nova-1732c373aa21fb7493b8fb50dd64bdf9425bf70b.zip | |
Gracefull shutdown of nova-api.
Diffstat (limited to 'bin/nova-api')
| -rwxr-xr-x | bin/nova-api | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/nova-api b/bin/nova-api index fff67251f..71c68f24d 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__': |
