我的行为模块中有以下停止功能:
start(_StartType, _StartArgs) ->
    ...
stop(_State) ->
    lager:info("Stop recieved."),
    erlang:display("Stop recieved."),
    ok.
Run Code Online (Sandbox Code Playgroud)
我的应用程序主管看起来像:
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API functions
%%====================================================================
start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
    {ok, { {one_for_all, 0, 1}, []} }.
Run Code Online (Sandbox Code Playgroud)
我不认为我曾经修改过那个文件。事实上,我觉得它如何连接到上面的start和stop函数有点神秘。
我的问题是,当我将 SIGTERM 发送到我正在运行的应用程序时,我没有看到stop函数中的日志记录语句出现。那看起来很糟糕。我需要向应用程序模块或主管模块添加一些东西吗?
(我需要处理 SIGTERM 并进行清理,因为我的应用程序是 Docker 化的并且 SIGTERM 被发送到在 Docker 内部运行的应用程序Docker stop,之后如果应用程序没有捕获 SIGTERM,它会在 10 秒后发送 SIGKILL。)
您需要像之前一样升级到刚刚发布的 Erlang 19.3 SIGTERM 被忽略。从发行说明:
erts:接收到的 SIGTERM 信号将向 init 进程生成一个“停止”消息,并很好地终止 Erlang VM。这相当于调用 init:stop/0。
http://www.erlang.org/news/110
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           633 次  |  
        
|   最近记录:  |