phoenixframework / phoenix

Peace of mind from prototype to production
https://www.phoenixframework.org
MIT License
21.41k stars 2.87k forks source link

Deploying to heroku? #233

Closed cheeyeo closed 10 years ago

cheeyeo commented 10 years ago

Hi

I have just created a phoenix app to test if it can be deployed to heroku.

I am following the instructions from https://github.com/sapporo-beam/phoenix-heroku and have tried to test locally by installing the dependency using

MIX_ENV=prod mix deps.get

Yet when I deploy to heroku it seems to grab all the dependencies but suddenly fails with

** (Mix) Could not start application ranch: could not find application file: ranch.app
ericmj commented 10 years ago

@cheeyeo Please show the output from the heroku deploy/compile. What Elixir version are you using?

cheeyeo commented 10 years ago

@ericmj I'm using elixir version 0.15.0. Please find the output below:

during compilation:

cheeyeo:websockets_terminal chee$ git push heroku master
Fetching repository, done.
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 988 bytes, done.
Total 7 (delta 5), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> elixir app detected
-----> Checking Erlang and Elixir versions
       Will use the following versions:
       * Erlang 17.0
       * Elixir 0.15.0 
-----> [skip] Already downloaded Erlang 17.0 
-----> Installing Erlang 17.0

-----> [skip] Already downloaded Elixir 0.15.0 
-----> [skip] Already unpacked and built Elixir
-----> Installing Elixir 0.15.0 
-----> Installing Hex
* creating /app/.mix/archives/hex.ez
-----> Installing rebar
* creating /app/.mix/rebar
-----> Fetching app dependencies with mix
* Getting phoenix (git://github.com/phoenixframework/phoenix.git)
Initialized empty Git repository in /tmp/build_a2b1940c-15ba-41ce-9c90-4ae33e7ff6f3/deps/phoenix/.git/
remote: Counting objects: 4397, done.        
remote: Compressing objects: 100% (1581/1581), done.        
remote: Total 4397 (delta 2727), reused 4109 (delta 2532)        
Receiving objects: 100% (4397/4397), 608.46 KiB, done.
Resolving deltas: 100% (2727/2727), done.
-----> Compiling app dependencies
==> linguist
warning: the dependency linguist requires Elixir "~> 0.14.1" but you are running on v0.15.0
==> ranch (compile)
Compiled src/ranch_transport.erl
Compiled src/ranch_acceptors_sup.erl
Compiled src/ranch_listener_sup.erl
Compiled src/ranch.erl
Compiled src/ranch_protocol.erl
Compiled src/ranch_sup.erl
Compiled src/ranch_ssl.erl
Compiled src/ranch_server.erl
Compiled src/ranch_tcp.erl
Compiled src/ranch_app.erl
Compiled src/ranch_acceptor.erl
Compiled src/ranch_conns_sup.erl
==> jazz
warning: the dependency jazz requires Elixir "~> 0.14.1" but you are running on v0.15.0
==> porcelain
warning: the dependency porcelain requires Elixir "~> 0.14.3" but you are running on v0.15.0
==> cowlib (compile)
Compiled src/cow_http.erl
Compiled src/cow_qs.erl
Compiled src/cow_spdy.erl
Compiled src/cow_cookie.erl
Compiled src/cow_http_te.erl
Compiled src/cow_http_hd.erl
Compiled src/cow_date.erl
Compiled src/cow_multipart.erl
Compiled src/cow_mimetypes.erl
==> cowboy (compile)
Compiled src/cowboy_middleware.erl
Compiled src/cowboy_sub_protocol.erl
Compiled src/cowboy_static.erl
Compiled src/cowboy_handler.erl
Compiled src/cowboy_loop_handler.erl
Compiled src/cowboy_router.erl
Compiled src/cowboy_sup.erl
Compiled src/cowboy_bstr.erl
Compiled src/cowboy_protocol.erl
Compiled src/cowboy_spdy.erl
Compiled src/cowboy_websocket.erl
Compiled src/cowboy.erl
Compiled src/cowboy_websocket_handler.erl
Compiled src/cowboy_clock.erl
Compiled src/cowboy_http_handler.erl
Compiled src/cowboy_app.erl
Compiled src/cowboy_rest.erl
Compiled src/cowboy_req.erl
Compiled src/cowboy_http.erl
lib/mix/tasks/phoenix.ex:1: warning: redefining module Mix.Tasks.Phoenix
lib/mix/tasks/phoenix/start.ex:1: warning: redefining module Mix.Tasks.Phoenix.Start
lib/mix/tasks/phoenix/routes.ex:1: warning: redefining module Mix.Tasks.Phoenix.Routes
lib/mix/tasks/phoenix/new.ex:1: warning: redefining module Mix.Tasks.Phoenix.New
==> phoenix
Compiled lib/mix/tasks/phoenix.ex
lib/phoenix.ex:1: warning: redefining module Phoenix
Compiled lib/mix/tasks/phoenix/routes.ex
lib/phoenix/adapters/cowboy.ex:1: warning: redefining module Phoenix.Adapters.Cowboy
Compiled lib/mix/tasks/phoenix/start.ex
lib/phoenix/channel.ex:1: warning: redefining module Phoenix.Channel
Compiled lib/mix/tasks/phoenix/new.ex
Compiled lib/phoenix.ex
Compiled lib/phoenix/adapters/cowboy.ex
lib/phoenix/config.ex:1: warning: redefining module Phoenix.Config
lib/phoenix/controller.ex:1: warning: redefining module Phoenix.Controller
lib/phoenix/controller/action.ex:1: warning: redefining module Phoenix.Controller.Action
lib/phoenix/config.ex:46: warning: redefining module Phoenix.Config.UndefinedConfigError
Compiled lib/phoenix/controller/action.ex
lib/phoenix/controller/connection.ex:1: warning: redefining module Phoenix.Controller.Connection
Compiled lib/phoenix/controller.ex
lib/phoenix/controller/errors.ex:1: warning: redefining module Phoenix.Controller.Errors
Compiled lib/phoenix/channel.ex
lib/phoenix/controller/errors.ex:3: warning: redefining module Phoenix.Controller.Errors.UnfetchedContentType
lib/phoenix/controller/flash.ex:1: warning: redefining module Phoenix.Controller.Flash
Compiled lib/phoenix/config.ex
lib/phoenix/html.ex:1: warning: redefining module Phoenix.Html
Compiled lib/phoenix/controller/flash.ex
Compiled lib/phoenix/controller/connection.ex
Compiled lib/phoenix/controller/errors.ex
lib/phoenix/html/engine.ex:1: warning: redefining module Phoenix.Html.Engine
lib/phoenix/plugs.ex:1: warning: redefining module Phoenix.Plugs
lib/phoenix/plugs/accepts.ex:1: warning: redefining module Phoenix.Plugs.Accepts
Compiled lib/phoenix/plugs.ex
Compiled lib/phoenix/plugs/accepts.ex
lib/phoenix/plugs/code_reloader.ex:1: warning: redefining module Phoenix.Plugs.CodeReloader
Compiled lib/phoenix/html/engine.ex
lib/phoenix/plugs/content_type_fetcher.ex:1: warning: redefining module Phoenix.Plugs.ContentTypeFetcher
lib/phoenix/plugs/error_handler.ex:1: warning: redefining module Phoenix.Plugs.ErrorHandler
Compiled lib/phoenix/plugs/code_reloader.ex
lib/phoenix/html.ex:17: warning: redefining module Phoenix.Html.Safe
lib/phoenix/plugs/params_fetcher.ex:1: warning: redefining module Phoenix.Plugs.ParamsFetcher
Compiled lib/phoenix/plugs/error_handler.ex
lib/phoenix/plugs/parsers/json.ex:1: warning: redefining module Phoenix.Plugs.Parsers.JSON
lib/phoenix/plugs/parsers/json.ex:8: warning: redefining module Phoenix.Plugs.Parsers.JSON.ParseError
Compiled lib/phoenix/plugs/params_fetcher.ex
Compiled lib/phoenix/plugs/content_type_fetcher.ex
lib/phoenix/plugs/session_fetcher.ex:1: warning: redefining module Phoenix.Plugs.SessionFetcher
lib/phoenix/plugs/router_logger.ex:1: warning: redefining module Phoenix.Plugs.RouterLogger
lib/phoenix/plugs/parsers/json.ex:15: warning: redefining module Plug.Exception.Phoenix.Plugs.Parsers.JSON.ParseError
Compiled lib/phoenix/plugs/session_fetcher.ex
lib/phoenix/project.ex:1: warning: redefining module Phoenix.Project
lib/phoenix/html.ex:21: warning: redefining module Phoenix.Html.Safe.Atom
Compiled lib/phoenix/project.ex
Compiled lib/phoenix/plugs/router_logger.ex
lib/phoenix/router/console_formatter.ex:1: warning: redefining module Phoenix.Router.ConsoleFormatter
lib/phoenix/router.ex:1: warning: redefining module Phoenix.Router
Compiled lib/phoenix/plugs/parsers/json.ex
lib/phoenix/router/errors.ex:1: warning: redefining module Phoenix.Router.Errors
lib/phoenix/html.ex:26: warning: redefining module Phoenix.Html.Safe.BitString
Compiled lib/phoenix/router/errors.ex
lib/phoenix/router.ex:77: warning: IO.ANSI.escape/1 is deprecated, use the new API in IO.ANSI.format/2 instead
lib/phoenix/html.ex:32: warning: redefining module Phoenix.Html.Safe.List
Compiled lib/phoenix/router/console_formatter.ex
Compiled lib/phoenix/router.ex
lib/phoenix/router/mapper.ex:1: warning: redefining module Phoenix.Router.Mapper
lib/phoenix/router/options.ex:1: warning: redefining module Phoenix.Router.Options
lib/phoenix/html.ex:60: warning: redefining module Phoenix.Html.Safe.Integer
lib/phoenix/router/path.ex:1: warning: redefining module Phoenix.Router.Path
lib/phoenix/html.ex:64: warning: redefining module Phoenix.Html.Safe.Float
Compiled lib/phoenix/router/options.ex
lib/phoenix/router/resources_context.ex:1: warning: redefining module Phoenix.Router.ResourcesContext
lib/phoenix/html.ex:70: warning: redefining module Phoenix.Html.Safe.Tuple
Compiled lib/phoenix/router/mapper.ex
lib/phoenix/router/scope_context.ex:1: warning: redefining module Phoenix.Router.ScopeContext
Compiled lib/phoenix/router/path.ex
lib/phoenix/router/socket.ex:1: warning: redefining module Phoenix.Router.Socket
Compiled lib/phoenix/router/resources_context.ex
lib/phoenix/router/stack.ex:1: warning: redefining module Phoenix.Router.Stack
Compiled lib/phoenix/router/socket.ex
lib/phoenix/socket.ex:1: warning: redefining module Phoenix.Socket
Compiled lib/phoenix/html.ex
Compiled lib/phoenix/router/scope_context.ex
lib/phoenix/socket/message.ex:1: warning: redefining module Phoenix.Socket.Message
Compiled lib/phoenix/router/stack.ex
lib/phoenix/status.ex:1: warning: redefining module Phoenix.Status
lib/phoenix/socket/handler.ex:1: warning: redefining module Phoenix.Socket.Handler
lib/phoenix/socket.ex:9: warning: redefining module Access.Phoenix.Socket
lib/phoenix/socket/message.ex:7: warning: redefining module Phoenix.Socket.Message.InvalidMessage
lib/phoenix/status.ex:7: warning: redefining module Phoenix.Status.InvalidStatus
lib/phoenix/socket/handler.ex:8: warning: redefining module Phoenix.Socket.Handler.InvalidReturn
Compiled lib/phoenix/socket/message.ex
Compiled lib/phoenix/socket.ex
lib/phoenix/supervisor.ex:1: warning: redefining module Phoenix.Supervisor
lib/phoenix/template.ex:1: warning: redefining module Phoenix.Template
Compiled lib/phoenix/supervisor.ex
Compiled lib/phoenix/status.ex
lib/phoenix/template/compiler.ex:1: warning: redefining module Phoenix.Template.Compiler
lib/phoenix/template.ex:4: warning: redefining module Phoenix.Template.UndefinedError
lib/phoenix/template/eex_engine.ex:1: warning: redefining module Phoenix.Template.EExEngine
Compiled lib/phoenix/socket/handler.ex
Compiled lib/phoenix/template/compiler.ex
lib/phoenix/template/engine.ex:1: warning: redefining module Phoenix.Template.Engine
lib/phoenix/topic.ex:1: warning: redefining module Phoenix.Topic
Compiled lib/phoenix/template/eex_engine.ex
lib/phoenix/topic/garbage_collector.ex:1: warning: redefining module Phoenix.Topic.GarbageCollector
Compiled lib/phoenix/template.ex
lib/phoenix/topic/server.ex:1: warning: redefining module Phoenix.Topic.Server
Compiled lib/phoenix/template/engine.ex
lib/phoenix/topic/supervisor.ex:1: warning: redefining module Phoenix.Topic.Supervisor
Compiled lib/phoenix/topic/garbage_collector.ex
lib/phoenix/view.ex:1: warning: redefining module Phoenix.View
Compiled lib/phoenix/topic/supervisor.ex
lib/phoenix/view/helpers.ex:1: warning: redefining module Phoenix.View.Helpers
Compiled lib/phoenix/topic.ex
lib/phoenix/view/helpers.ex:2: warning: unused alias View
Compiled lib/phoenix/view.ex
Compiled lib/phoenix/view/helpers.ex
Compiled lib/phoenix/topic/server.ex
Generated phoenix.app
cp: cannot stat `/app/.mix/hex.ets': No such file or directory
-----> Compiling the app
Compiled lib/websockets_terminal.ex
Compiled lib/websockets_terminal/supervisor.ex
Compiled web/channels/shell.ex
Compiled lib/websockets_terminal/shell_server.ex
Compiled web/i18n.ex
Compiled web/views.ex
Compiled web/controllers/page_controller.ex
Compiled web/views/layout_view.ex
web/templates/page/index.html.eex:1: warning: variable assigns is unused
Compiled web/views/page_view.ex
Compiled web/router.ex
Generated websockets_terminal.app
Consolidated Plug.Exception
Consolidated Phoenix.Html.Safe
Consolidated Jazz.Decoder
Consolidated Jazz.Encoder
Consolidated Collectable
Consolidated Access
Consolidated Range.Iterator
Consolidated Inspect
Consolidated Enumerable
Consolidated String.Chars
Consolidated List.Chars
Consolidated protocols written to _build/prod/consolidated
-----> Creating .profile.d with env vars
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 57.2MB
-----> Launching... done, v11
       http://phoenix-websockets.herokuapp.com/ deployed to Heroku

When running the application, it crashes with ranch.app not found as shown below:

2014-08-03T15:58:41.016074+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-03T15:58:48.546791+00:00 app[web.1]: Consolidated Plug.Exception
2014-08-03T15:58:48.653024+00:00 app[web.1]: Consolidated Jazz.Encoder
2014-08-03T15:58:48.790345+00:00 app[web.1]: Consolidated Enumerable
2014-08-03T15:58:48.583606+00:00 app[web.1]: Consolidated Phoenix.Html.Safe
2014-08-03T15:58:48.704525+00:00 app[web.1]: Consolidated Jazz.Decoder
2014-08-03T15:58:48.864601+00:00 app[web.1]: Consolidated String.Chars
2014-08-03T15:58:49.009238+00:00 app[web.1]: Consolidated Inspect
2014-08-03T15:58:48.908828+00:00 app[web.1]: Consolidated List.Chars
2014-08-03T15:58:49.089018+00:00 app[web.1]: Consolidated Range.Iterator
2014-08-03T15:58:49.185076+00:00 app[web.1]: Consolidated Collectable
2014-08-03T15:58:49.231495+00:00 app[web.1]: Consolidated Access
2014-08-03T15:58:49.231685+00:00 app[web.1]: Consolidated protocols written to _build/prod/consolidated
2014-08-03T15:58:45.425876+00:00 heroku[web.1]: Starting process with command `yes | mix compile.protocols && MIX_ENV=prod PORT=4001 elixir -pa _build/prod/consolidated -S mix phoenix.start`
2014-08-03T15:58:50.980237+00:00 app[web.1]: ** (Mix) Could not start application ranch: could not find application file: ranch.app
2014-08-03T15:58:52.299752+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-03T15:58:52.292020+00:00 heroku[web.1]: Process exited with status 1
2014-08-03T15:58:53.988155+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=phoenix-websockets.herokuapp.com request_id=451b269b-db50-49b7-bf96-15fd0e5815d0 fwd="54.83.118.7" dyno= connect= service= status=503 bytes=

I have logged into the heroku remote server and checked the _build/prod/lib directory and the ranch directory is not there which is causing it to fail?

any help is most appreciated

thanks

chee

chrismccord commented 10 years ago

Can you pull the latest phoenix master and retry? The mix.lock contained an incorrect ranch dep, but it was fixed late yesterday after 0.15.0 support was added.

ericmj commented 10 years ago

There seems to be other strange things going on with all "module redefined" warnings.

chrismccord commented 10 years ago

I just successfully deployed the phoenix_chat_example app to Heroku (phoenix master, elixir 0.15.0). I'm using HashNuke's buidpack as well. Can you take a look at the example app and see if there's something you're missing? https://github.com/chrismccord/phoenix_chat_example

cheeyeo commented 10 years ago

hi @chrismccord I will try it out :+1: thanks again for your help

cheeyeo commented 10 years ago

hi @chrismccord I managed to get it to work by following your setup in your example application posted above. Thanks again for your help :+1: :+1:

jeregrine commented 10 years ago

@chrismccord might be a good thing to add to the wiki? "Deploying to heroku" or even a blog post I suppose.

josevalim commented 10 years ago

I don't like wikis because they get horrible outdated and unless you have someone actively taking care of it, it becomes a mess very quickly. For Dynamo, we had a bunch of howto/guides in the repository. You could consider something similar here, be it in this repo or in another one. For now, since there is still a lot of code churn, doing in the same repo sounds like a good idea.

josevalim commented 10 years ago

https://github.com/dynamo/dynamo/tree/master/guides

jeregrine commented 10 years ago

The guides can get just as outdated. :trollface: but yea I understand I have no opinion on where it goes.

josevalim commented 10 years ago

Guides are easier to be updated on the repo because when you do backwards incompatible changes it is easier to grep. Another advantage of guides is that we would receive PRs for changing them, instead of free access like in the wiki, so we can guarantee quality. The idea though is to have dozens of guides covering the most important bits.

jeregrine commented 10 years ago

:+1: