elixirdistillery

Elixir app on VPS can't started from ssh on daemon mode


I've been built an app with Phoenix + Elixir and deploy it to server with distillery. Everything worked fine, until I try to create some bash script to automate deployment, FYI: I've been tried edeliver but it didn't fit my need. I'm always successful when try to run app on daemon mode on my VPS when I logged on and run

sudo my_app/bin/app start

But, when I run ssh with remote command

ssh user@some_ip -C "sudo my_app/bin/app start"

It failed to start with no output on the shell screen. It just won't worked.

But, if I run on foreground mode with

ssh user@some_ip -C "sudo my_app/bin/app foreground"

It will be successful start the app and show the running log I've been trying using nohup on foreground mode but it still showing the running log, while I need to run another command

Is there any required step to run SSH remote command, some environment set maybe ?


Solution

  • This smells like an XY problem. Running a remote with plain bin/app start is a very bad idea in the first place. One should use either upstart or systemd (or another process scheduler) to ensure the application will be up and running after it’s started.

    Once properly set, you’ll execute something like

    ssh user@some_ip -C "sudo systemctl start app"
    

    and the glitch you currently experience should just go away.