如何更改Erlang makefile以使其启用SMP模式?

时间:2018-04-12 19:26:11

标签: erlang erlang-shell smp erl

我想开发一个需要SMP的应用程序。但是在我使用的Erlang makefile中,选项是在非smp模式下设置的。因此,当我启动应用程序时,我在Shell中收到错误,指示需要SMP仿真器,并且我应该从erl -smp开始。如何更改Erlang makefile以启用SMP模式?
PS:erl -smp命令在命令提示符下工作,即当我不使用makefile时。

2 个答案:

答案 0 :(得分:0)

请注意,smp版本通常是默认版本(除非您在单个核心计算机上运行,​​在这种情况下您可能需要强制它),并且非smp版本实际上将从代码库从下一个主要版本(OTP 21)开始 - 您仍然可以在单个核心机器上运行,但代码不适用于单核心情况。 (这大大简化了仿真器代码,删除了大量#ifdefs。)

答案 1 :(得分:0)

不知道makefile的确切解决方案,但这可能会有所帮助

# Makefile

.PHONY: all compile run

REBAR=./rebar3

all: compile

compile:
    $(REBAR) compile

run: compile
        erl -pa _build/default/lib/*/ebin -config config/sys.config -args_file config/vm.args -boot start_sasl -s sync -s yourawesomeapp

至于我,我总是将vm.args文件与rebar3

一起使用

这是代码的例子

## Name of the node
-name node@10.00.0.00

## Cookie for distributed erlang
-setcookie test_cookie

## Enable kernel poll and a few async threads
+K true
+A 2

## Force the erlang VM to use SMP
-smp enable

## Increase number of concurrent ports/sockets
-env ERL_MAX_PORTS 65535