1

I've been trying to setup a Webmachine app on Heroku, using the buildpack recommended. My Procfile is

# Procfile
web: sh ./rel/app_name/bin/app_name console

Unfortunately this doesn't start the dyno correctly, it fails with

2015-12-08T16:34:55.349362+00:00 heroku[web.1]: Starting process with command `sh ./rel/app_name/bin/app_name console`
2015-12-08T16:34:57.387620+00:00 app[web.1]: Exec: /app/rel/app_name/erts-7.0/bin/erlexec  -boot /app/rel/app_name/releases/1/app_name -mode embedded -config /app/rel/app_name/releases/1/sys.config -args_file /app/rel/app_name/releases/1/vm.args -- console
2015-12-08T16:34:57.387630+00:00 app[web.1]: Root: /app/rel/app_name
2015-12-08T16:35:05.396922+00:00 app[web.1]: 16:35:05.396 [info] Application app_name started on node 'app_name@127.0.0.1'
2015-12-08T16:35:05.388846+00:00 app[web.1]: 16:35:05.387 [info] Application lager started on node 'app_name@127.0.0.1'
2015-12-08T16:35:05.399281+00:00 app[web.1]: Eshell V7.0  (abort with ^G)
2015-12-08T16:35:05.399283+00:00 app[web.1]: (app_name@127.0.0.1)1> *** Terminating erlang ('app_name@127.0.0.1')
2015-12-08T16:35:06.448742+00:00 heroku[web.1]: Process exited with status 0
2015-12-08T16:35:06.441993+00:00 heroku[web.1]: State changed from starting to crashed

But when I run the same command via heroku toolbelt, it starts up with the console.

$ heroku run "./rel/app_name/bin/app_name console"
Running ./rel/app_name/bin/app_name console on tp-api... up, run.4201
Exec: /app/rel/app_name/erts-7.0/bin/erlexec  -boot /app/rel/app_name/releases/1/app_name -mode embedded -config /app/rel/app_name/releases/1/sys.config -args_file /app/rel/app_name/releases/1/vm.args -- console
Root: /app/rel/app_name
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

16:38:43.194 [info] Application lager started on node 'app_name@127.0.0.1'
16:38:43.196 [info] Application app_name started on node 'app_name@127.0.0.1'
Eshell V7.0  (abort with ^G)
(app_name@127.0.0.1)1>

Is there way to start the node, maybe as a daemon on the dyno(s)?

Note I've tried to use start instead of console, but that did not yield any success.

Máté
  • 2,294
  • 3
  • 18
  • 25
  • Is there not some other logfile in rel/app_name/log/ accumulating anything useful when it fails? – Michael Dec 08 '15 at 18:51
  • I couldn't get anything out, I think that's more down to how heroku deals with their dynos/virtual machines, not persisting files in them. – Máté Dec 09 '15 at 11:12
  • @Michael I got it working in the end, see the answer below. I'd prefer to run the release executable there, but this will do for now. – Máté Dec 09 '15 at 15:17

1 Answers1

1

So after much tinkering, trial and error, figured out what was wrong. Heroku does not like the interactive shell to be there - hence the crash on starting the Erlang app through console fails.

I've adjusted my Procfile, to the following:

# Procfile
web: erl -pa $PWD/ebin $PWD/deps/*/ebin -noshell -boot start_sasl -s reloader -s app_name -config ./rel/app_name/releases/1/sys

Which boots up the application app_name, using the the release's sys.config configuration file. What was crucial here, is to have the -noshell option in the command, that allows heroku to run the process as they expect it.

Máté
  • 2,294
  • 3
  • 18
  • 25
  • this is probably because backend processes are started w/o a stdin. The console wants to read from in and fails. – ZeissS Dec 10 '15 at 22:39
  • There MUST be some way to give those arguments to a a release too. Check the release file or sthg. – ZeissS Dec 14 '15 at 12:34