Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edeliver Starting Phoenix/Elixir App on Random TCP Port

We are trying to deploy our Phoenix Web App to a Linux VM (in our case on Azure) using edeliver We have deployed a "basic" Blog App to Azure using edeliver and documented the steps: https://github.com/dwyl/learn-microsoft-azure#part-2-deploying-your-application

And when we manually run the ("real") app: https://github.com/nelsonic/healthlocker on the instance using MIX_ENV=prod mix phoenix.server it runs fine!

When we deploy and run the app to the Azure instance using the following commands:

mix edeliver build release --verbose
mix edeliver deploy release to production
mix edeliver start production

We get a positive confirmation message:

EDELIVER HEALTHLOCKER WITH START COMMAND

-----> starting production servers

production node:

  user    : root
  host    : 51.140.86.5
  path    : /home/hladmin
  response: ok


START DONE!

However when we run netstat -plnt as suggested by checking-running-services-on-linux we notice that edeliver is starting the Phoenix App on a random TCP Port:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:29130         0.0.0.0:*               LISTEN      3759/mdsd
tcp        0      0 0.0.0.0:38863           0.0.0.0:*               LISTEN      56269/beam.smp
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      32642/epmd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1557/sshd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      16901/postgres
tcp6       0      0 :::4369                 :::*                    LISTEN      32642/epmd
tcp6       0      0 :::22                   :::*                    LISTEN      1557/sshd

In this case the app is running on PORT 38863, even thought our prod.exs config file has hard coded the PORT to 4000 and we have an Environment Variable to set it to 4000 in our .profile file as per the instructions (just-in-case).

So my questions are:

Why is edeliver start the Phoenix App on a Random TCP PORT...?

and

How do I get edeliver to boot the app on PORT 4000?

Our .deliver/config is on GitHub.

We have attempted to read the logs in /home/{username}/{appname}/var/log as per @dogbert's instructions in: How to View Production Logs in Phoenix Web Application Deployed using Edeliver? But neither erlang.log.1 or run_erl.log made us any wiser... :-(

Any help understanding this would be much appreciated! (Please & Thanks!)

Note: Sadly, while this Q: Edeliver - Impossible to access on port 4000 after successful deploy sounds similar, the solution does not work for us (we tried)

like image 931
nelsonic Avatar asked Jun 30 '17 21:06

nelsonic


1 Answers

It looks to me like you didn't read the Phoenix documentation for deploying via releases. Distillery also has documentation for this.

In a gist, this is what you need in your config:

config :healthlocker, Healthlocker.Endpoint
  server: true,
  root: ".",
  version: Mix.Project.config[:version]

Ensure those three config options are set in your prod config.exs file, and you should be good to go.

like image 183
bitwalker Avatar answered Oct 20 '22 12:10

bitwalker