[Kimchi-devel] [PATCH] [WoK 5/5] reload API: adding notification before reloading operation
Daniel Henrique Barboza
dhbarboza82 at gmail.com
Wed Jan 18 20:47:12 UTC 2017
On 01/18/2017 04:03 PM, Lucio Correia wrote:
> On 18/01/2017 14:24, dhbarboza82 at gmail.com wrote:
>> From: Daniel Henrique Barboza <danielhb at 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 at 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..02adcdd 100644
>> --- a/src/wok/i18n.py
>> +++ b/src/wok/i18n.py
>> @@ -62,4 +62,6 @@ messages = {
>> "WOKRES0001L": _("Request made on resource"),
>> "WOKROOT0001L": _("User '%(username)s' login"),
>> "WOKROOT0002L": _("User '%(username)s' logout"),
>> +
>> + "WOKCONFIG0001I": _("WoK is going to restart. Existing WoK
>> connections will be closed."),
> To not mix with user log messages, include this one before the ones
> ending in L.
>
Alright!
>
>> }
>> 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='/')
>
> It may be working this way, but it should work as well with
> plugin_name=None. It makes more sense to be None than '/', since there
> is no plugin '/'. Anyway, just a suggestion.
Yeah, it works either way. I've asked Aline her option on it (I have no
favorites
between plugin_name='/' and plugin_name=None and even
plugin_name='wok') and she said that she prefers '/'. You can interpret it
as 'this is not a plugin, this is the root URI'. But I agree that None
works too.
>
>
>> + # 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()
>>
>
>
More information about the Kimchi-devel
mailing list