|
Revision 12334, 1.4 kB
(checked in by topia, 5 years ago)
|
|
* start implementation.
|
-
Property svn:mime-type set to
text/x-perl; charset=UTF-8
-
Property svn:eol-style set to
LF
-
Property svn:keywords set to
Id URL Date Rev Author
|
| Line | |
|---|
| 1 | # ----------------------------------------------------------------------------- |
|---|
| 2 | # $Id$ |
|---|
| 3 | # ----------------------------------------------------------------------------- |
|---|
| 4 | # confやモジュールのリロードの引き金。 |
|---|
| 5 | # ----------------------------------------------------------------------------- |
|---|
| 6 | package ReloadTrigger; |
|---|
| 7 | use strict; |
|---|
| 8 | use warnings; |
|---|
| 9 | use RunLoop; |
|---|
| 10 | use Configuration; |
|---|
| 11 | use ModuleManager; |
|---|
| 12 | use Timer; |
|---|
| 13 | |
|---|
| 14 | sub reload_conf_if_updated { |
|---|
| 15 | # confファイルが更新されていたらリロードし、 |
|---|
| 16 | # Tiarra内のそれぞれのクラスにconfの更新を通知する。 |
|---|
| 17 | # モジュール側で更新された場合になにかの処理をするには、 |
|---|
| 18 | # Configuration::Hook の reloaded を使ってください。 |
|---|
| 19 | if (Configuration->shared_conf->check_if_updated) { |
|---|
| 20 | Configuration->shared_conf->load; |
|---|
| 21 | RunLoop->shared_loop->update_networks; |
|---|
| 22 | ModuleManager->shared_manager->update_modules; |
|---|
| 23 | } |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | sub reload_mods_if_updated { |
|---|
| 27 | ModuleManager->shared_manager->reload_modules_if_modified; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | sub reload_all_if_updated { |
|---|
| 31 | if (Configuration->shared_conf->check_if_updated) { |
|---|
| 32 | Configuration->shared_conf->load; |
|---|
| 33 | RunLoop->shared_loop->update_networks; |
|---|
| 34 | } |
|---|
| 35 | ModuleManager->shared_manager->update_modules( |
|---|
| 36 | check_module_update => 1, |
|---|
| 37 | ); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | sub _install_reload_timer { |
|---|
| 41 | Timer->new( |
|---|
| 42 | Name => __PACKAGE__.'/reload', |
|---|
| 43 | After => 0, |
|---|
| 44 | Code => sub { |
|---|
| 45 | reload_all_if_updated; |
|---|
| 46 | } |
|---|
| 47 | )->install; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | 1; |
|---|