X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=inline;f=modules%2Ferl%2Feuphorik_daemon.erl;h=190458e203d977bbb4d7d92a3164b2e657616671;hb=HEAD;hp=f50affe6ab865908bc374c4583ba403e21055bd8;hpb=145974d77e365d720a83778626f7855eaa8e9b3f;p=euphorik.git
diff --git a/modules/erl/euphorik_daemon.erl b/modules/erl/euphorik_daemon.erl
index f50affe..190458e 100755
--- a/modules/erl/euphorik_daemon.erl
+++ b/modules/erl/euphorik_daemon.erl
@@ -1,24 +1,61 @@
-% Module tournant en background s'occupant periodiquement de certaines tâches.
-% Auteur : G.Burri
-% Date : 05.11.2007
+% coding: utf-8
+% Copyright 2008 Grégory Burri
+%
+% This file is part of Euphorik.
+%
+% Euphorik is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Euphorik is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Euphorik. If not, see .
+%
+% Module tournant en background s'occupant periodiquement de certaines tâches :
+% - rechargement des modules lors d'une mise en production
--module(euphorik_daemon).
--export([start/1]).
-
+
+-module(euphorik_daemon).
+-author("Greg Burri ").
+-export([start/1, reload_euphorik/0, loop/0]).
-include("../include/euphorik_defines.hrl").
-
-
-% Démarre le démon
-start(A) ->
- loop(A).
-
-loop(A) ->
- euphorik_bd:elire_troll(),
- %
-
- timer:sleep(1000),
- loop(A).
-
-
+% Démarre le démon
+start(_A) ->
+ register(euphorik_daemon, self()),
+ loop().
+
+
+loop() ->
+ receive
+ switch -> % To reload a new code, see 'reload_euphorik/0'.
+ euphorik_daemon:loop()
+ end.
+
+% Recharge tous les modules euphorik.
+% Appelé lors d'une mise en prod.
+% TODO : récupérer les noms à partir des .beam dans /modules/ebin
+reload_euphorik() ->
+ lists:foreach(
+ fun(M) ->
+ c:l(M) % (purge & load)
+ end,
+ [
+ euphorik_common,
+ euphorik_minichat_conversation,
+ euphorik_protocole,
+ euphorik_requests,
+ euphorik_bd,
+ euphorik_bd_admin,
+ euphorik_daemon
+ ]
+ ),
+ % changement du code du daemon
+ euphorik_daemon ! switch,
+ ok.