From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
This patch adds an add_notification call to warn the UI
about the pending reload process. To allow the UI to actually
see the notification before WoK restarts, a 2 seconds wait
(value defined by the wok.NOTIFICATION_INTERVAL var in
wok.main.js) is given before sending the cherrypy.engine.restart
call.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
src/wok/i18n.py | 2 ++
src/wok/model/config.py | 15 +++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/wok/i18n.py b/src/wok/i18n.py
index e454e31..dc101eb 100644
--- a/src/wok/i18n.py
+++ b/src/wok/i18n.py
@@ -55,6 +55,8 @@ messages = {
"WOKUTILS0004E": _("Invalid data value '%(value)s'"),
"WOKUTILS0005E": _("Invalid data unit '%(unit)s'"),
+ "WOKCONFIG0001I": _("WoK is going to restart. Existing WoK connections
will be closed."),
+
# These messages (ending with L) are for user log purposes
"WOKASYNC0001L": _("Successfully completed task
'%(target_uri)s'"),
"WOKASYNC0002L": _("Failed to complete task
'%(target_uri)s'"),
diff --git a/src/wok/model/config.py b/src/wok/model/config.py
index 57c5ad8..b69f2dd 100644
--- a/src/wok/model/config.py
+++ b/src/wok/model/config.py
@@ -18,8 +18,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import cherrypy
+import time
from wok.config import config, get_version
+from wok.model.notifications import add_notification
+from wok.utils import wok_log
class ConfigModel(object):
@@ -34,4 +37,16 @@ class ConfigModel(object):
'version': get_version()}
def reload(self, name):
+ add_notification('WOKCONFIG0001I', plugin_name='/')
+ # If we proceed with the cherrypy.engine.restart() right after
+ # adding the notification, the server will reboot and the
+ # opened UIs will most likely not see the notification at all. The
+ # notification interval is set in wok.main.js as:
+ #
+ # wok.NOTIFICATION_INTERVAL = 2000
+ #
+ # Inserting a time.sleep(2) here will ensure that all opened
+ # UI had the chance to see the reload notification.
+ wok_log.info('Reloading WoK in two seconds ...')
+ time.sleep(2)
cherrypy.engine.restart()
--
2.7.4