Erlang在生产中启动应用程序 [英] Erlang start application in production
问题描述
当我在本地主机上测试我的erlang应用程序时,我有一个脚本启动服务器,如下所示:
When I'm testing my erlang application on localhost, I have a script that starts the server that looks like the following:
#!/bin/sh
PWD="$(pwd)"
NAME="$(basename $PWD)"
erl -pa "$PWD/ebin" deps/*/ebin -boot start_sasl \
-name devnode@127.0.0.1 \
-s reloader \
-s $NAME \
-setcookie some_random_cookie \
+K true \
+P 65536
这将提示打开Erlang shell从那里我会输入:
This prompts open the Erlang shell and from there I would type something like:
应用程序:start(myapp)
这对于开发目的来说很好,但是如何在生产中部署?到目前为止,我可以想到这样做的唯一方法是通过启动屏幕过程并将其分离出来。我不认为应该是这样。我正在使用钢筋,如果这有帮助。
This is fine for development purposes, but how do I deploy this in production? As of right now, the only way I can think of doing this is by starting a screen process and detaching from it. I don't think that should be the case. I am using rebar, if that helps at all.
推荐答案
听起来像你想使用自定义的引导脚本。一个引导脚本告诉erlang系统什么开始。在您正在使用的脚本中,您正在设置引导脚本:
Sounds like you want to use a custom boot script. A boot script tells the erlang system what to start. In the script you're using, you're setting the boot script with:
-boot start_sasl
http://www.erlang.org/doc/system_principles/system_principles.html ,查找用户定义的启动脚本一节
http://www.erlang.org/doc/system_principles/system_principles.html, look for the section "User-Defined Boot Scripts"
更简单的选择可能是将您的应用程序转换为使用钢筋: https://github.com/basho/rebar。然后,您可以执行以下操作:
An easier option may be to convert your application to use rebar: https://github.com/basho/rebar. You would then be able to do the following:
./rebar compile generate
这将为应用程序创建一个发行版,然后允许您:
This will create a release for the application, allowing you to then:
./rel/<app_name>/bin/<app_name>
相同的原则,只是全部包装起来容易使用。
Same principles, just all wrapped up for easy use.
这篇关于Erlang在生产中启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!