启动erlang代码的脚本
我正在尝试在 ubuntu 上构建一个脚本来启动我的一些 Erlang 代码:
该脚本类似于:
#!/bin/sh
EBIN=$HOME/path_to_beams
ERL=/usr/local/bin/erl
export HEART_COMMAND="$EBIN/starting_script start"
case $1 in
start)
$ERL -sname mynode -pa $EBIN \
-heart -detached -s my_module start_link
;;
*)
echo "Usage: $0 {start|stop|debug}"
exit 1
esac
exit 0
但我遇到了一些问题。
首先,只有当脚本与梁位于同一目录中时才能执行代码,这对我来说似乎很奇怪,我仔细检查了路径,那么为什么 -pa 标志不起作用?
其次,脚本(没有 -pa )工作正常,但是如果我尝试启动而不是主模块(gen_server)它的主管(-s my_module_sup start_link)它不起作用......这很奇怪,因为如果我从普通的 shell 启动主管,一切正常。
第三,-heart 标志,应该在失败的情况下重新启动脚本,但是如果我使用正常的 Unix 终止来终止进程,则该进程不会重新启动。
有人可以给我一些提示吗?
预先感谢,
pdn
I am trying to build a script on ubuntu to start some Erlang code of mine:
the script is something like:
#!/bin/sh
EBIN=$HOME/path_to_beams
ERL=/usr/local/bin/erl
export HEART_COMMAND="$EBIN/starting_script start"
case $1 in
start)
$ERL -sname mynode -pa $EBIN \
-heart -detached -s my_module start_link
;;
*)
echo "Usage: $0 {start|stop|debug}"
exit 1
esac
exit 0
but I'm having a couple of problems.
First of all, the code can be executed only if the script is in the same directory as the beams, this seems strange to me, I double checked the paths, so why doesn't the -pa flag work?
Second, the script (without the -pa) works fine, but if I try to start instead of the main module (a gen_server) its supervisor (-s my_module_sup start_link) it doesn't work...this is strange, because if I start the supervisor from a normal shell everything works fine.
Third, the -heart flag, should restart the script in case of failure, but if I kill the process with a normal Unix kill, the process is not restarted.
Can someone give me some hints?
Thanks in advance,
pdn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先想到的是您使用的是
erlexport
而不是erl
。不确定你为什么要这样做(我以前没有听说过 erlexport )。请尝试使用erl
来代替。如果 Erlang 节点本身被杀死,那么您的
-heart
标志将没有任何意义,因为该进程无法保持自身存活。您需要运行另一个进程来监视 Erlang 进程并在被终止时重新启动它。The first thing that comes to mind is that you're using
erlexport
instead oferl
. Not sure why you're doing this (I've not heard oferlexport
before). Try it witherl
instead.Your
-heart
flag won't have meaning if the Erlang node itself is killed because the process can't keep itself alive. You would need another process running that monitors the Erlang process and restarts it if killed.