s-stepien

s-stepien

Hi

I have fairly complicated Phoenix app (but it doubt that this is Phoenix related issue?). In it I have the MyApp.Application module with start(_type, _args) function. I noticed today (after long time without working on it), that the start() function isn’t called at all. In the mix.exs file, the mod: is set correctly to that module - I haven’t changed anything there.

How one can try to debug this? What is happening before call to start() - maybe something there hangs?

I’ve tried rebuild from scratch, re-get deps, etc. And nothing, the function will not be called.
When I created new project, all seems OK in it.

I’m using Erlang/OTP 28.1 and Elixir 1.18.4

Update:
If I use MIX_ENV=prod, then I can see print at the beginning of the start() function. But I want to use the dev env :slight_smile:

Showing Posts 13 to 4

s-stepien

s-stepien OP

Hmmm

In fail case:

iex(2)> Application.started_applications()
[
{:myapp, [], []},
{:hex, ~c"hex", ~c"2.2.2"},
{:inets, ~c"INETS  CXC 138 49", ~c"9.4.2"},
{:ssl, ~c"Erlang/OTP SSL application", ~c"11.4"},
{:public_key, ~c"Public key infrastructure", ~c"1.18.3"},
{:asn1, ~c"The Erlang ASN1 compiler version 5.4.2", ~c"5.4.2"},
{:crypto, ~c"CRYPTO", ~c"5.7"},
{:mix, ~c"mix", ~c"1.18.4"},
{:iex, ~c"iex", ~c"1.18.4"},
{:elixir, ~c"elixir", ~c"1.18.4"},
{:compiler, ~c"ERTS  CXC 138 10", ~c"9.0.2"},
{:stdlib, ~c"ERTS  CXC 138 10", ~c"7.1"},
{:kernel, ~c"ERTS  CXC 138 10", ~c"10.4"}
]

iex(4)> Application.ensure_started(:phoenix_live_reload)
{:error, {:not_started, :logger}}
iex(5)> Application.ensure_started(:logger)
:ok
iex(6)> Application.ensure_started(:phoenix_live_reload)
{:error, {:not_started, :phoenix}}
iex(7)> Application.ensure_started(:phoenix)
{:error, {:not_started, :eex}}
iex(8)> Application.ensure_started(:eex)
:ok
iex(9)> Application.ensure_started(:phoenix)
{:error, {:not_started, :plug}}
iex(10)> Application.ensure_started(:plug)
{:error, {:not_started, :mime}}
iex(11)> Application.ensure_started(:mime)
:ok
iex(12)> Application.ensure_started(:plug)
{:error, {:not_started, :plug_crypto}}
iex(13)> Application.ensure_started(:plug_crypto)
:ok
iex(14)> Application.ensure_started(:plug)
{:error, {:not_started, :telemetry}}
iex(15)> Application.ensure_started(:telemetry)
:ok
iex(16)> Application.ensure_started(:plug)
:ok
iex(17)> Application.ensure_started(:phoenix)
{:error, {:not_started, :phoenix_pubsub}}
iex(18)> Application.ensure_started(:phoenix_pubsub)
:ok
iex(19)> Application.ensure_started(:phoenix)
{:error, {:not_started, :phoenix_template}}
iex(20)> Application.ensure_started(:phoenix_templete)
{:error, {~c"no such file or directory", ~c"phoenix_templete.app"}}

Update: in the end I was able to start them all and made sure that the file is there. So I do not know if this is related (or if I’m doing it correctly anyway).

dimitarvp

dimitarvp

Let us know when you dig the problem out. Should be something trivial that the tooling does not yell at you for but must be this or that, I presume.

s-stepien

s-stepien OP

Yes, I’ve redacted the true app name and redacted the paths with the app name. However, there is not one line in patters list that would cause the issue (I’ve checked). I have to remove this whole config section to see the apps starting. So I think it is not about the dir/files the inotify observes.

And yes, with new/clean project, the live_reload isn’t blocking the startup. In new project and in my project I’m using the same versions of the packages (e.g. file_system). I’ve also checked the code generated in new project - it looks the same (only some patters are different).

Update: empty patters also helps! So I do not have to remove the whole section from config file.

dimitarvp

dimitarvp

I take it that you redacted the app name and module namespace in the snippet above and they’re not the same in the real code? Just making sure.

Also does this code look the same in a freshly generated project?

s-stepien

s-stepien OP

It seems that the issue is with:

# Watch static and templates for browser reloading.
config :myapp, MyAppWeb.Endpoint,
  live_reload: [
    patterns: [
      ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"priv/gettext/.*(po)$",
      ...
    ]
  ]

Without this feature configured, the dev comes up. I wonder what might be the issue here. I will double check my paths here.

jswanner

jswanner

diff _build/{dev,prod}/lib/<app_name>/ebin/<app_name>.app
dimitarvp

dimitarvp

Then the culprit should be config/prod.exs or config/runtime.exs or any code that branches on the environment variables.

garrison

garrison

That is odd. I don’t know off the top of my head anything that would cause that behavior, though perhaps someone else will think of something.

Given that the behavior is different between environments you may want to comb through the configs for anything that could be different, though again I’m not sure what that might be.

As for your question about what happens when the application starts, it’s described quite thoroughly in the Application docs.

s-stepien

s-stepien OP

@garrison none of the children are started. The function is not called/entered.

@jswanner even with raise “here” it will not stop it. I’m using iex -S mix phx.server with some env variables.

Note that with MIX_ENV=prod it works, every time. With MIX_ENV=dev it does not. Only this MIX_ENV is different in invocation.

jswanner

jswanner

I believe @garrison is trying to get at is if any of the children in your application are running, if so then your application is running, and your endpoint is an easy one to test if it’s running.

How are you running your application? mix phx.server from the terminal, or some other way? Is it possible something is swallowing that IO you are using to debug? Instead of IO.inspect("here") you can try raise "here"

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews