Erlang:rebar3发布,首先开始梁?
我试图在19.3中使用一个新的function: Erlang:应用程序行为陷阱SIGTERM?
我的理解是发送SIGTERM到BEAM现在会触发Erlang 19.3+的正常closures
我使用ENTRYPOINT ./_build/default/rel/myapp/bin/myapp
在Docker中启动我的应用程序,其中./_build/default/rel/myapp/bin/myapp
是从rebar3 release
生成的
当我在Docker中这样做的时候, myapp
得到了PID1,而BEAM似乎又获得了另一个PID。
是否有一组不同的命令,我可以运行,使BEAM得到PID1和myapp从那里加载? 就像是
./start_beam; ./start_my_app_via_beam
./start_beam; ./start_my_app_via_beam
?
我需要这个,因为docker stop
发送SIGTERM到PID1。 我需要那个BEAM。 使用上面的入口点,这里是在容器中发生的事情“: top PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 4340 644 556 S 0.0 0.0 0:00.01 myapp 14 root 20 0 3751188 50812 6660 S 0.0 0.6 0:00.48 beam.smp 18 root 20 0 11492 116 0 S 0.0 0.0 0:00.00 epmd 31 root 20 0 4220 680 604 S 0.0 0.0 0:00.10 erl_child_setup 53 root 20 0 11456 944 840 S 0.0 0.0 0:00.00 inet_gethost 54 root 20 0 17764 1660 1504 S 0.0 0.0 0:00.00 inet_gethost 55 root 20 0 20252 3208 2720 S 0.0 0.0 0:00.02 bash 61 root 20 0 21956 2468 2052 R 0.0 0.0 0:00.00 top
目前,为了解决这个问题,我有这个可怕的野兽:
#!/usr/bin/env bash echo "if testing locally send SIGTERM to $$" term_handler() { echo "Stopping the Erlang VM gracefully" #/usr/local/Cellar/erlang/19.1/lib/erlang/lib/erl_interface- 3.9.1/bin/erl_call -c myapp -s -a 'init stop' -n 'myapp@localhost' /usr/local/lib/erlang/lib/erl_interface-3.9.2/bin/erl_call -c myapp -s -a 'init stop' -n 'myapp@localhost' echo "Erlang VM Stopped" } trap term_handler SIGQUIT SIGINT SIGTERM ./_build/default/rel/myapp/bin/myapp & PID=$! echo "Erlang VM Started" #wait $PID while kill -0 $PID ; do wait $PID ; EXIT_STATUS=$? ; done echo "Exiting Wrapper." exit $EXIT_STATUS ``` And then I do `ENTRYPOINT : ["./thisscript"]`
这个野兽变成PID 1,然后find正确的东西杀了。
我试图摆脱这个脚本。