Phoenix-app monitoring and systemd

Hello, guys!
I want to monitor my phoenix app’s life with systemd tool
(like,omg, what if my supervisor fails).
So I need it’s pid to be stored somewhere. So I need edeliver to create pid file right after deploy.
But edeliver doesn’t seem to have after deploy hooks, only after build ones. What should I do?
How do you usually monitor your apps?
Could it be that there is a better way to know if my app is alive rather than using systemd?

1 Like

Finally managed to find the solution:
I misunderstood things and there are actually after deploy hooks in edeliver.

in .deliver/config file:

post_start_deployed_release() {
  if [ "$TARGET_MIX_ENV" = "prod" ]; then
    arr=(`echo ${PRODUCTION_HOSTS}`);
    for host in ${arr[@]}; do
      `ssh pepe@${host} "mkdir -p ~/pepe_project/var/run && /usr/sbin/lsof -i:4000 | grep beam.smp | awk '{print $2}' > ~/pepe_project
1 Like

I’d probably have the BEAM itself make a PID file during application startup or so, although my server has to work on linux and windows both. ^.^;

1 Like

Yeah, you are right!
Nothing prevents me from running lsof from the application itself.

1 Like