hashrocket / gatling

Deployment tool for Phoenix apps
496 stars 17 forks source link

When git push to upgrade, server runs in dev mode. #22

Closed loongmxbt closed 7 years ago

loongmxbt commented 7 years ago

When git push production master and then visit url, it shows

function Phoenix.LiveReloader.call/2 is undefined (module Phoenix.LiveReloader is not available)

seems it uses phoenix_live_reload module which is only for dev.

remote: $ mix release --upgrade --upfrom=0.0.1479980159 --warnings-as-errors --env=prod (/root/starsoul)
remote: ==> Assembling release..
remote: ==> Building release starsoul:0.0.1479988632 using environment prod
remote: ==> Including ERTS 8.1 from /usr/lib/erlang/erts-8.1
remote: ==> Generated .appup for starsoul 0.0.1479980159 -> 0.0.1479988632
remote: ==> Relup successfully created
remote: ==> Packaging release..
remote: ==> Release successfully built!
remote:     You can run it in one of the following ways:
remote:       Interactive: rel/starsoul/bin/starsoul console
remote:       Foreground: rel/starsoul/bin/starsoul foreground
remote:       Daemon: rel/starsoul/bin/starsoul start
remote: $ service starsoul upgrade 0.0.1479988632
remote: Release 0.0.1479988632 not found, attempting to unpack releases/0.0.1479988632/starsoul.tar.gz
remote: Unpacked successfully: "0.0.1479988632"
remote: Installed Release: 0.0.1479988632
remote: Made release permanent: "0.0.1479988632"
To root@106.14.40.86:starsoul
   3154393..723ea37  master -> master

How to solve this problem? Where did I miss? Thanks a lot!

loongmxbt commented 7 years ago

in proj_name/rel/config.exs, change default_environment to :prod and run mix gatling.deploy proj_name.

Seems when upgrade it uses the rel/config default environment setup, but first deploy will build prod.

PS: After modifying rel/config.exs, upgrade still uses dev causes error, but deploy uses prod works fine, what did I do wrong.

Need to do service proj_name stop and service proj_name start

mrmicahcooper commented 7 years ago

Hey @loongmxbt, what I typically do on the production server is globally set the MIX_ENV variable to prod

Here is a link to do this in the docs: https://github.com/hashrocket/gatling#deploying-your-app

dennisreimann commented 7 years ago

I came across this too. For me the root cause of this is the sudo security policy that leads to a fresh environment for commands that run via sudo. I've added the necessary --preserve-env statements and hints with this commit: 17ca79f97b368c0961c61733647914975eac95bb

loongmxbt commented 7 years ago

We should deploy the app via a sudo user instead of the root user. Check den's guide!