% 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).
-author("Greg Burri ").
-export([start/1, reload_euphorik/0, loop/0]).
-include("../include/euphorik_defines.hrl").
% 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.