How do you deal with Releases and Secret Key?

I’m using releases for my web app and every time I create a new release I have to create a new secret key as it’s kept as a env variable. Because of that, all my users are signed out everytime I publish a new release. Is there a better way to handle this?

Where are you setting the secret key? You said it comes from an env variable, so what’s stopping you from leaving the old value in there?

1 Like

I don’t think you need to run mix phx.gen.secret for each new deploy you make.

How do You manage reboot?

I tried it but when I create a new release I get a message that secret key is not set or something like that. The same thing happens with db settings, every time I have to set username, password and database name. I can create several releases without creating new key if I don’t close my terminal, but if I do, I have to set it again. I’m not sure why is this happening.

How do You manage reboot?

It doesn’t matter if I reboot it or not.

It does because You need to provide secret key again…

So, I don’t have to create a new one each time but I do have to provide it every time? And if I use the same key, my users won’t be signed out?

Yes, and usually You manage this with systemd.

Could you explain this to me a little bit? How exactly do you manage it with systemd?

Systemd can transform your release into a service… that could be started at boot time.

You configure a service for your release, that knows about your secret… and how to start/stop your release.

1 Like

This sounds very intersting, I will look into it. Thank you.

Let’s take a step back here and don’t assume anything.

Can you tell us exactly:

  • how (distillery or mix) and where (locally, on CI, or somewhere else) you build your release
  • how and where you run your release
  • when exactly you encounter the issue
  • what the error message is exactly (copy paste it, if at all possible)

Based on that we should be able to help you better