Forum

Need some help? Ask our community for its assistance!

You are not logged in.

#1 23-07-2019 08:14:47

oncletom
Membre
From: Crest, Vallée de la Drôme
Registered: 15-04-2011
Posts: 13
Website

Trouble running an Elixir site

Hello,

I created an Elixir site using Alwaysdata, to run Pleroma and test the self-hosting of my own Mastodon instance.
I'm used to create Node.js apps but for some reason, I cannot work out Elixir Apps.

Whatever I do, I have the "Connection to upstream skipped".
In the site logs, I have this:

[22/Jul/2019:23:08:21 +0200] [upstream] Upstream starting: MIX_ENV=prod mix phx.server (env: {'LANG': 'en_US.UTF-8', 'ALWAYSDATA_HTTPD_PORT': '8101', 'IP': '127.0.84.235', 'MIX_ENV': 'prod', 'ALWAYSDATA_HTTPD_IP': '127.0.84.235', 'ELIXIR_VERSION': '1.7.4', 'LC_ALL': 'en_US.UTF-8', 'HOME': '/home/oncletom', 'PORT': '8101'}, cwd: /home/oncletom/pleroma)
[22/Jul/2019:23:08:21 +0200] [upstream] Upstream started PID: 1672641
[22/Jul/2019:23:08:21 +0200] [upstream] Upstream starting failed: MIX_ENV=prod mix phx.server (return code: 127 | reason: -)

I assume the error code 127 means the command does not exist. So maybe the env variable in the command messes things up. Nevertheless, I try with the env variable in the "Environment" field. Different output but same error:

[22/Jul/2019:23:08:21 +0200] [upstream] Upstream starting: mix phx.server (env: {'LANG': 'en_US.UTF-8', 'ALWAYSDATA_HTTPD_PORT': '8101', 'IP': '127.0.84.235', 'MIX_ENV': 'prod', 'ALWAYSDATA_HTTPD_IP': '127.0.84.235', 'ELIXIR_VERSION': '1.7.4', 'LC_ALL': 'en_US.UTF-8', 'HOME': '/home/oncletom', 'PORT': '8101'}, cwd: /home/oncletom/pleroma)
[22/Jul/2019:23:08:21 +0200] [upstream] Upstream started PID: 1672641
[22/Jul/2019:23:08:21 +0200] [upstream] Upstream starting failed: mix phx.server (return code: 127 | reason: -)

So if I sum up the things:

  • when I SSH in the right CWD, then run `MIX_ENV=prod mix phx.server`…

    • the server is up and running

    • but when I connect to the domain, it displays "Connection to upstream skipped"

    • if I do `curl http://127.0.84.235:8101` (in SSH), I see the expected app output

  • when I prefix a command with an env variable (like `MIX_ENV=prod`), it seems to be understood rather as a command (like MIX_ENV=prod is the name of the executable)

  • when I set MIX_ENV=prod in the Environment field, it sounds like the app misses its dependencies, as if it would be started in a different environment than "prod"… so I'm confused here

On a side note, I tried running this Node.js command (from the Site > Command field) and in a shell :

npx serve -l tcp://0.0.0.0:8101

.
Well, I still face "Connection to upstream skipped"… but I can curl to this server I SSH on alwaysdata.

Thanks for your help

Last edited by oncletom (23-07-2019 08:15:45)

Offline

#2 23-07-2019 08:56:09

@Cyril
Staff
From: Paris
Registered: 06-02-2007
Posts: 5,660
Website

Re: Trouble running an Elixir site

Hello,

First, the SSH server is distinct from the HTTP server, so it's normal you'd have a "Connection to upstream skipped" even if you started manually (over SSH) your command.

Second, the "MIX_ENV=prod" part should indeed not be in the command field but in the environment field, otherwise as you suspected, it would try to find the MIX_ENV=prod command.

I'm surprisingly not getting the same results as you when running the command over SSH:

oncletom@ssh4:/home/oncletom/pleroma$ MIX_ENV=prod mix phx.server
Unchecked dependencies for environment prod:
* prometheus_plugs (Hex package)
  the dependency is not available, run "mix deps.get"
* ex_aws_s3 (Hex package)
  the dependency is not available, run "mix deps.get"
* html_sanitize_ex (Hex package)
...

Can you show me what an "env" returns? I'm suspecting a difference between our environments.

Offline

#3 23-07-2019 10:15:48

oncletom
Membre
From: Crest, Vallée de la Drôme
Registered: 15-04-2011
Posts: 13
Website

Re: Trouble running an Elixir site

Indeed.

I ran a clean install and this is what is logged in the site logs:

[23/Jul/2019:10:01:20 +0200] [upstream] Upstream starting: mix phx.server (env: {'LANG': 'en_US.UTF-8', 'ALWAYSDATA_HTTPD_PORT': '8101', 'IP': '127.0.84.235', 'MIX_ENV': 'prod', 'ALWAYSDATA_HTTPD_IP': '127.0.84.235', 'ELIXIR_VERSION': '1.7.4', 'LC_ALL': 'en_US.UTF-8', 'HOME': '/home/oncletom', 'PORT': '8101'}, cwd: /home/oncletom/pleroma)
[23/Jul/2019:10:01:20 +0200] [upstream] Upstream started PID: 1666582
[23/Jul/2019:10:01:20 +0200] [upstream] [1666582] STDOUT: Mix.env(): :prod
[23/Jul/2019:10:01:20 +0200] [upstream] [1666582] STDOUT: MIX_ENV: "prod"
[23/Jul/2019:10:01:20 +0200] [upstream] [1666582] STDOUT: PORT: "8101"
[23/Jul/2019:10:01:20 +0200] [upstream] [1666582] STDOUT: HOME: "/home/oncletom"
[23/Jul/2019:10:01:20 +0200] [upstream] [1666582] STDOUT: Could not find Hex, which is needed to build dependency :phoenix
[23/Jul/2019:10:01:20 +0200] [upstream] [1666582] STDERR: ** (Mix) Could not find an SCM for dependency :phoenix from Pleroma.Mixfile
[23/Jul/2019:10:01:20 +0200] [upstream] Upstream starting failed: mix phx.server (return code: 1 | reason: -)

It's strange because when logged into a shell, the app starts normally.

So it sounds like the env variable is correctly detected but something differs from the shell and the Site's process management.
Maybe the $PATH is different?

On the shell I have `"/usr/lib/erlang/erts-8.2.1/bin:/usr/lib/erlang/bin:/home/oncletom/www/.gem/ruby/2.4.0/bin:/home/oncletom/www/.local/bin:/home/oncletom/www/.composer/vendor/bin:/home/oncletom/www/.npm-packages/bin:/usr/alwaysdata/nodejs/8.15.1/bin:/usr/alwaysdata/elixir/1.7.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"`.

Offline

#4 23-07-2019 10:40:59

@Cyril
Staff
From: Paris
Registered: 06-02-2007
Posts: 5,660
Website

Re: Trouble running an Elixir site

OK I got it: you have a non-standard HOME (/home/oncletom/www rather than /home/oncletom), which explains the issue. Manually setting HOME=/home/oncletom/www in the environment field fixes the issue smile

Offline

#5 23-07-2019 11:46:50

oncletom
Membre
From: Crest, Vallée de la Drôme
Registered: 15-04-2011
Posts: 13
Website

Re: Trouble running an Elixir site

@Cyril wrote:

OK I got it: you have a non-standard HOME (/home/oncletom/www rather than /home/oncletom), which explains the issue. Manually setting HOME=/home/oncletom/www in the environment field fixes the issue smile

Woah, nice catch! I would not have found/guessed it without you.
Thanks a bunch smile

Last edited by oncletom (23-07-2019 11:47:11)

Offline

Board footer

Powered by FluxBB