summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/base/app_manager.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index 357d34d6..c28ed74a 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -31,6 +31,7 @@ import os
from ryu import cfg
from ryu import utils
+from ryu.app import wsgi
from ryu.controller.handler import register_instance, get_dependent_services
from ryu.controller.controller import Datapath
from ryu.controller import event
@@ -326,6 +327,25 @@ class AppManager(object):
_instance = None
@staticmethod
+ def run_apps(app_lists):
+ """Run a set of Ryu applications
+
+ A convenient method to load and instantiate apps.
+ This blocks until all relevant apps stop.
+ """
+ app_mgr = AppManager.get_instance()
+ app_mgr.load_apps(app_lists)
+ contexts = app_mgr.create_contexts()
+ services = app_mgr.instantiate_apps(**contexts)
+ webapp = wsgi.start_service(app_mgr)
+ if webapp:
+ services.append(hub.spawn(webapp))
+ try:
+ hub.joinall(services)
+ finally:
+ app_mgr.close()
+
+ @staticmethod
def get_instance():
if not AppManager._instance:
AppManager._instance = AppManager()