繁体   English   中英

在Heroku中为Phoenix Framework设置MIX_ENV

[英]Setting MIX_ENV in Heroku for Phoenix Framework

我成功地实例化了两个Heroku应用程序:my-app-prod和my-app-test。 我在Heroku应用程序设置中配置了特定的环境变量。 我在Phoenix使用标准配置文件:config.exs,test.exs,prod.exs,dev.exs。

在Heroku中使用app变量MIX_ENV = test配置my-app-test后,它仍然从prod.exs加载变量。

我还缺少任何额外的步骤,以便我的应用程序使用test.exs吗?

我按照这里的所有说明操作: https//hexdocs.pm/phoenix/heroku.html

当我运行git push时,我可以根据以下输出验证它是否正在使用prod.exs。

 remote: Generated my_phoenix_app_name app remote: -----> Creating .profile.d with env vars remote: -----> Writing export for multi-buildpack support remote: -----> Executing post compile: pwd remote: /tmp/build_f5b9e6e5890fcb58b9689f433c554c6a remote: -----> Phoenix app detected remote: remote: -----> Loading configuration and environment remote: Loading config... remote: Detecting assets directory remote: * package.json found in custom directory remote: Will use phoenix configuration: remote: * assets path . remote: * mix tasks namespace phoenix remote: Will use the following versions: remote: * Node 5.3.0 remote: Will export the following config vars: remote: CLIENT_ID remote: DATABASE_URL remote: POOL_SIZE remote: SECRET_KEY_BASE remote: SHOPIFY_SECRET remote: * MIX_ENV=prod 

Elixir的MIX_ENV 默认MIX_ENV设置为prod ,因此您在Procfile中实际上不需要此设置。 您可以将其更改为:

web: mix phoenix.server

my-app-prod你不需要做任何事情。 my-app-test上设置MIX_ENV进行test 您可以使用命令行

heroku config:set MIX_ENV=test --app my-app-test

如果它不起作用,请尝试将您的应用重新部署到Heroku。

在您的Procfile ,它说:

web: MIX_ENV=prod mix phoenix.server

你应该能够把它改成:

web: mix phoenix.server

由于您已经在应用程序的设置配置变量中设置了MIX_ENV ,因此您应该可以将MIX_ENV部分关闭。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM