Gracefull shutdown of nova-api.

This commit is contained in:
Nikolay Sokolov
2011-07-04 23:48:05 +04:00
parent 40d3a53b37
commit cd1dcaf9ef
2 changed files with 10 additions and 5 deletions

View File

@@ -93,3 +93,4 @@ Yoshiaki Tamura <yoshi@midokura.jp>
Youcef Laribi <Youcef.Laribi@eu.citrix.com>
Yuriy Taraday <yorik.sar@gmail.com>
Zhixue Wu <Zhixue.Wu@citrix.com>
Nikolay Sokolov <nsokolov@griddynamics.com>

View File

@@ -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,6 +35,10 @@ 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."""
@@ -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__':