Where to put restart='always' in systemd for Phoenix App

Hi Sorry I accidentally sent my unfinished question here is the edit,

I found this example of using systemd to deploy Phoenix. My quesiton is where do I put restart=‘always’ inside this,
[Unit]
Description=Runner for My Phoenix App
After=network.target

[Service]
WorkingDirectory=/opt/path_to_my_phoenix_app
EnvironmentFile=/etc/default/my_phoenix_app.env
ExecStart=/opt/path_to_my_phoenix_app/bin/my_phoenix_app start
ExecStop=/opt/path_to_my_phoenix_app/bin/my_phoenix_app stop
User=ubuntu
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Please let me know if something is wrong with this example. Thanks.

Could you share that example? You should use [Service] section. You can check out my quite complex example that uses other fancy systemd features.

6 Likes

please let me know if there is something wrong with my example.

Assuming that you are using mix release, not Distillery then RemainAfterExit is incorrect as you do not fork into background (in general if you can, you should NOT daemonize in systemd services). I would use Require in addition to After. You can also check my example linked above together with systemd library for better integration (notification socket, watchdog, and journal integration).

2 Likes