X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_daemon.erl;h=b802bbe5c86517b82d9ed930b954cc7bef96acbf;hp=f50affe6ab865908bc374c4583ba403e21055bd8;hb=81393a74d648e4830dc8c7c562fa203f50a105f6;hpb=145974d77e365d720a83778626f7855eaa8e9b3f diff --git a/modules/erl/euphorik_daemon.erl b/modules/erl/euphorik_daemon.erl index f50affe..b802bbe 100755 --- a/modules/erl/euphorik_daemon.erl +++ b/modules/erl/euphorik_daemon.erl @@ -1,24 +1,62 @@ -% Module tournant en background s'occupant periodiquement de certaines tâches. -% Auteur : G.Burri +% 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 % Date : 05.11.2007 +% @author G.Burri --module(euphorik_daemon). --export([start/1]). - + +-module(euphorik_daemon). +-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 -> % permet de substituer le code du process par un nouveau code, voir reload_euphorik + 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.