Heroku Procfile not working - heroku

I'm trying use Nginx + Phalcon. So I have the root folder (app) and my public folder (app/public).
Inside the root (app) I have the Procfile:
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
And inside my public folder I have my index.php
<?php exit('hello');
With this simple example, shouldn't print hello when I access the url myapp.herokuapp.com?
If my thought is right, which is not working. My second problem is that the nginx_app.conf seems that are not been reading by the server. Because every f* page that I tried access I got 404.
So, what am I doing wrong?
[UPDATED]
Here's the log:
heroku[web.1]: State changed from down to starting
heroku[web.1]: Starting process with command `php -S 0.0.0.0:57262`
heroku[web.1]: State changed from starting to up
app[web.1]: [Tue Apr 7 11:08:07 2015] 10.185.81.31:28258 Invalid request (Unexpected EOF)
app[web.1]: [Tue Apr 7 11:08:07 2015] 172.19.28.141:33686 Invalid request (Unexpected EOF)
heroku[router]: at=info method=GET path="/" host=myapp.herokuapp.com request_id=d39f119a-fd95-4887-809f-74712925606f fwd="200.221.158.131" dyno=web.1 connect=2ms service=4ms status=404 bytes=668
app[web.1]: [Tue Apr 7 11:08:44 2015] 10.61.196.230:38679 [404]: / - No such file or directory
[UPDATED]
$ git push ...
[...]
remote: -----> Discovering process types
remote: Procfile declares types -> web
$ heroku run bash
$ cat Procfile
~ $ : vendor/bin/heroku-php-nginx public/~ $
And according the documentation should be
heroku run bash
Running `bash` attached to terminal... up, run.5662
$ cat Procfile
web: vendor/bin/heroku-php-apache2
A little detail that I have tried:
cat Procfile
~ $ vendor/bin/heroku-php-nginx public/c/~ $
vendor/bin/heroku-php-nginx public/
DOCUMENT_ROOT changed to 'public/'
Optimzing defaults for 1X dyno...
4 processes at 128MB memory limit.
Starting php-fpm...
Starting nginx...
I'm waiting... let's see what happens

Something is wrong with your Procfile; as you can see, Heroku is booting in the default php -S mode. This happens when a Procfile is present, but no "web" process type is declared; this should also be written out in a message towards the very end of a git push heroku master (something about the Procfile not declaring a "web" process type and it then using a default).
That rules out your Procfile not being checked into Git or having the wrong name (e.g. lowercase procfile).
The culprit is very, very likely a Unicode Byte Order Mark that the editor you're using is inserting at the beginning of the file: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
So your Procfile doesn't look like this:
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
but actually like this:
\0xEF\0xBB\0xBFweb: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
Your editor (and most editors for that matter) simply don't display the BOM.
To fix the issue, save your Procfile without a BOM (and, while your at it, configure your editor to never save a UTF-8 BOM, because its use is highly discouraged and causes myriads of problems just like this one).

Related

Problem deploying Phoenix app to Gigalixir: "No file named server#127.0.0.1"

I am trying to deploy Hashrockets TIL Phoenix App to Gigalixir.
This is what I get after push to Gigalixir:
2020-08-23T05:58:55.071975+00:00 til[gigalixir-run]: Attempting to start 'til' on host 'til-6c4c5d7854-ddpfh'
2020-08-23T05:58:55.071987+00:00 til[gigalixir-run]: Attempting health checks on port 4000
2020-08-23T05:58:55.874467+00:00 til[til-6c4c5d7854-ddpfh]: web.1 | started with pid 49
2020-08-23T05:58:57.568099+00:00 til[til-6c4c5d7854-ddpfh]: web.1 | No file named server#127.0.0.1
2020-08-23T05:58:57.976006+00:00 til[til-6c4c5d7854-ddpfh]: web.1 | exited with code 1
2020-08-23T05:58:57.976034+00:00 til[til-6c4c5d7854-ddpfh]: system | sending SIGTERM to all processes
I cannot make sense of the error message No file named server#127.0.0.1. What can I do now?
The reason for this problem is, that the Procfile coming with the project is probably meant to be used with Heroku and contains
web: MIX_ENV=prod elixir --cookie $OTP_COOKIE --name server#127.0.0.1 --erl '-kernel inet_dist_listen_min 9000' --erl '-kernel inet_dist_listen_max 9000' -S mix phx.server
Renaming the file to Procfile.disabled and thus making Gigalixir use its default Procfile solves this problem.

Phoenix deployment on Heroku failed to bind $PORT

I have big issues with deploying my application on heroku server. I've done it with help of tutorial from phoenix webpage. But it doesn't work. Below you can see the logs and configuration i used.
heroku logs
2016-02-07T04:28:55.623435+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2016-02-07T04:28:55.623435+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-02-07T04:28:56.344649+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-02-07T04:28:56.348324+00:00 heroku[web.1]: Process exited with status 137
2016-02-07T09:54:29.124036+00:00 heroku[web.1]: State changed from crashed to st
arting
2016-02-07T09:54:34.703208+00:00 heroku[web.1]: Starting process with command `m
ix run --no-halt`
2016-02-07T09:55:35.386922+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2016-02-07T09:55:35.386922+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-02-07T09:55:36.330258+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-02-07T09:55:36.323082+00:00 heroku[web.1]: Process exited with status 137
2016-02-07T12:14:35.182306+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=kpsz.herokuapp.com request_id=7de0ee97-14cf-46f9-
a9a3-cbffa09ac379 fwd="83.7.11.212" dyno= connect= service= status=503 bytes=
2016-02-07T12:14:35.850018+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=kpsz.herokuapp.com request_id=4e9b1979
-deb6-497b-80b2-655615f43d01 fwd="83.7.11.212" dyno= connect= service= status=50
3 bytes=
Configuration prod.exs
config :kpsz, Kpsz.Endpoint,
http: [port: System.get_env("PORT")],
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/manifest.json",
secret_key_base: System.get_env("SECRET_KEY_BASE")
config :kpsz, Kpsz.Repo,
adapter: Ecto.Adapters.Postgres,
url: System.get_env("DATABASE_URL"),
pool_size: 20
I'm not sure if that's the problem but you could try to replace
http: [port: System.get_env("PORT")]
with
http: [port: {:system, "PORT"}]
At least that's what I'm using in my apps. You can also read the docs for more information http://www.phoenixframework.org/docs/heroku
I had a similar problem.
Adding a Procfile with a single line web: mix phoenix.server solved it.
heroku destroy project name
heroku create
and for some weird reason it works now...
Thanks very much for help.
I ran into this issue and, for me, the fix was as follow (copied from the answer on this question).
The fix is twofold:
to use the phoenix buildpack config and export the PORT as well, like so: config_vars_to_export=(DATABASE_URL PORT)
Avoid changing the MIX_ENV without recompiling the app, as that behavior is unsupported, as explained here.
As Recreation solves the problem, I suspect the problem is with loading environment variables.
Once I had a similar problem in my local. My observations
mix phoenix.server (you might see the message compiled so and so files)
Stopped the server
Export/Change the env variable in zshrc/bashrc file and source it
Start the server (you might not see that compilation message, as there are no changes in your codebase and so your new/edited env variables won't get reflected)
If you just add a space in that file will make it compile and take that env variable.
Reason for your problem might be: Setting env variables after the server is running/deployed, as env variables are converted to value during the compilation time itself.
I had a similar problem when deploying the phoenix umbrella project with docker.
I've taken these steps:
Heroku https://hexdocs.pm/phoenix/heroku.html#deploying-to-heroku-using-the-container-stack
Dockerfile https://hexdocs.pm/phoenix/releases.html#containers
I've also looked at other links, but these two was the best.
The only problem with that Dockerfile is that it needs $PORT (and $SECRET_KEY_BASE) on the build step which is not present. So we have to "stub" it somehow in prod.exs. BUT we have to provide real $PORT on a run step (runtime configuration). So you have to be sure that you renamed config/prod.secret.exs to config/releases.exs (the 1 step at https://hexdocs.pm/phoenix/releases.html#runtime-configuration) or just create config/releases.exs which would rewrite $PORT (and maybe some other application environment variables - for example, $SECRET_KEY_BASE).
UPD: as #Daniel mentions - releases is an Elixir 1.9 feature.

Erlang/Webmachine doesn't start on heroku

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.
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.

Running War file with Jetty Runner in Heroku

If someone could give me some help on heroku I would appreciate.
If I run this command on my local console, it works on -> localhost:8080
java -jar tools/jetty-runner-7.6.3.jar --port 8080 target/scala-2.9.1/myapp.war
So then I create the Procfile with this:
web: java -jar tools/jetty-runner-7.6.3.jar --port 8080 target/scala-2.9.1/myapp.war
Then I test by running:
foreman start
and it also works in -> localhost:8080
But after I deployed the app and make heroku open, it does not work...
[success] Total time: 1 s, completed Jun 22, 2012 11:16:59 AM
-----> Discovering process types
Procfile declares types -> web
-----> Compiled slug size is 70.0MB
-----> Launching... done, v5
http://myapp.herokuapp.com deployed to Heroku
To git#heroku.com:myapp.git
XXXXX..XXXXX master -> master
$heroku logs
2012-06-22T11:14:54+00:00 heroku[slugc]: Slug compilation started
2012-06-22T11:17:57+00:00 heroku[api]: Release v5 created by my_email#my_email.com
2012-06-22T11:17:57+00:00 heroku[api]: Deploy dcdd123 by my_email#my_email.com
2012-06-22T11:18:00+00:00 heroku[slugc]: Slug compilation finished
2012-06-22T11:18:21+00:00 heroku[router]: Error H14 (No web processes running) -> GET myapp.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-06-22T11:18:30+00:00 heroku[router]: Error H14 (No web processes running) -> GET myapp.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
Any ideas, suggestions? Thanks,
Regards,
Andre
Andre - We have a Heroku Labs feature that allows you to deploy WAR files directly to Heroku. Check out https://gist.github.com/a8c62301591a11b4c6e9 for exact details on how to go about doing it.
If you are using jetty runner to run your war you do not need to hard code the port number.
Heroku sets the port internally.
So your Procfile should be like:
java -jar tools/jetty-runner-7.6.3.jar --port $PORT target/scala-2.9.1/myapp.war

Deploying Play 2.0 app on Heroku

So I am kind of new to setting up servers. And I have been struggling with various sql issues all night. I think the only thing that sits between me and a successfully running play app is this: error
Starting process with command `target/start -Dhttp.port=80 `
2012-04-04T05:58:52+00:00 app[web.1]: Play server process ID is 1
2012-04-04T05:58:53+00:00 app[web.1]: [info] play - database [default] connected at jdbc:mysql://us-cdbr-east.cleardb.com/heroku_cd914b667dae168
2012-04-04T05:58:56+00:00 app[web.1]: [info] play - Application started (Prod)
2012-04-04T05:58:56+00:00 app[web.1]: Oops, cannot start the server.
2012-04-04T05:58:56+00:00 app[web.1]: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:80
... more errors
Does anyone spot any problems? Do I need any java options arguments?
I tried specifying a user port in the Procfile, and got a different error message:
2012-04-04T07:01:36+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=2000`
2012-04-04T07:01:37+00:00 app[web.1]: Play server process ID is 1
2012-04-04T07:01:40+00:00 app[web.1]: [info] play - database [default] connected at jdbc:mysql://us-cdbr-east.cleardb.com/heroku_cd914b667dae168
2012-04-04T07:01:45+00:00 app[web.1]: [info] play - Application started (Prod)
2012-04-04T07:01:45+00:00 app[web.1]: [info] play - Listening for HTTP on port 2000...
2012-04-04T07:01:46+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 2000, should be 47248 (see environment variable PORT)
2012-04-04T07:01:46+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-04-04T07:01:47+00:00 heroku[web.1]: Process exited with status 137
2012-04-04T07:01:47+00:00 heroku[web.1]: State changed from starting to crashed
I have no idea what is happening. How do I change this environment variable? This heroku process model is very confusing to me.
I think the problem is that you're not allowing Heroku to specify the port. Googling your error I find: https://devcenter.heroku.com/articles/error-codes#r11__bad_bind
So instead of doing this:
web: target/start -Dhttp.port=80
Do this
web: target/start -Dhttp.port=$PORT
James has a nice writeup on getting a more advanced Play 2.0 app deployed here.

Resources