slouchpie

slouchpie

Using project's .iex.exs with gigalixir ps:remote_console

Gigalixir lets us start a remote shell, similar to iex --remsh. The command is:

gigalixir ps:remote_console -a my-app

Does anyone know if there is a way to make this shell use my project’s .iex.exs. I want this because my .iex.exs contains lots of nice aliases. I get very tired of typing alias MyApp.SomeContext.SomeModule.

Marked As Solved

jesse

jesse

Perhaps you can try adding the .iex.exs file as an overlay to get it included in the release. mix release — Mix v1.20.2

Also Liked

slouchpie

slouchpie

I’ve said it before and I’ll say it again. This forum is sooo good. The advice people give is such high-quality. It’s like living next to the Mage’s Guild.

slouchpie

slouchpie

This is the solution! I just copied my project’s .iex.exs to rel/overlays/.iex.exs and re-deployed and YATA! it worked!

Thanks @jesse

LostKobrakai

LostKobrakai

You can do this:

Last Post!

slouchpie

slouchpie

The benefit of iex.exs is being able to print helpful reminder messages in a production/staging/dev shell.

Example:

is_staging = !!System.get_env("IS_STAGING")

mix_env =
  case {System.get_env("MIX_ENV"), Application.get_env(:my_app, :env)} do
    {"prod", :prod} -> :prod
    {_, :test} -> :test
    {_, :dev} -> :dev
    _ -> :unknown
  end

print_warning = fn message ->
  IO.puts(IO.ANSI.red_background() <> message <> IO.ANSI.blink_rapid() <> IO.ANSI.reset())
end

print_info = fn message ->
  IO.puts(IO.ANSI.cyan_background() <> message <> IO.ANSI.reset())
end

print_warning_if_prod = fn ->
  case {mix_env, is_staging} do
    {:prod, false} ->
      for message <- ["⚠ REMINDER:", "👿 THIS IS THE PROD SHELL!", "🙇 PLEASE BE CAREFUL."] do
        print_warning.(message)
      end

    {:prod, true} ->
      print_warning.("👷 this is the staging shell")

    {_, _} ->
      print_info.("Welcome to MyApp, Dev 👽")
  end
end

print_warning_if_prod.()
print_info.(" 🌎 Your region: " <> System.get_env("FLY_REGION", "local-dev"))

With the above (or similar) in the iex.exs file, connecting to remote shells is safer. The developer is reminded of the environment.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
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
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement