blset

blset

Problem with app dir using release

Hello,

it’s not clear what is the app dir with releases

I have files generated by the phoenix web app that can be downloaded.
They are stored in a directory called downs of the app dir. if I change release I expect these files to stay where they are and be found by all releases

I have added
plug Plug.Static, at: "/downs", from: Path.expand('./downs'), gzip: false
I then generate urls with /downs/xxx

1- if I run the app with mix phx.server from the app dir it works ok
2- if I run the app with _build/rel/prod/v1/bin/v1 start from the app dir (after having build the release) it works ok

the problem is :

3- if I upload the release previoulsy built (on another machine) to another directory test1 with the downs dir copied into test1 (but not in priv/static) , and from test1 I run v1/bin/v1 start, the app works ok but the files in downs are not found

I uploaded in test1 only the content of v1, not the full tree _build/prod/rel/v1

the url is correctly generated but looks like the plug static line is ignored in case 3

thanks for any advice

in short

> test1
> - downs
>    - file1
> - v2
>   - all files generated by mix release found under _build/prod/rel/v2 originally

file1 present when generating the release is found
but a file2 put by the application when running the release is not found for download although the url are exaclty similar

/downs/file1
/downs/file2

since file2 was put by the running application the app dir is ok but the download of the file intercepted by plug static works for file1 but not for file2

Marked As Solved

blset

blset

I thought it worked but in fact that does not work because at compile time

Application.get_env(:my_app, :downs_path) || Path.expand(’./downs’),

Application.get_env returns nil so you get the path of the machine which builds the release not the runtime path

I ended up with

plug Plug.Static, at: “/downs”, from: {:vf, “../../../downs”},

that is a relative path which saves the need for the ENV var

Also Liked

kokolegorille

kokolegorille

Another reliable way is to use a path relative to

:code.priv_dir(:your_app)

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New

We're in Beta

About us Mission Statement