0

I have a spring app that is happily running on a staging and a prod server. It's time to automate deployments.

I have a restart.sh script on my staging server. if I ssh into the server and run it as a user everything works as expected.

command to run: nohup ./restart.sh

# restart.sh
kill  $(ps -aux | grep plenti-app | grep java | awk '{print $2}')
java -jar -Dspring.profiles.active=staging plenti-app

However, when I attempt to run the command through ssh, it fails saying that password authentication for my database fails.

ssh user@$STAGING_IP "./restart.sh"

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "gszbybjk"
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:520) ~[postgresql-42.2.9.jar!/:42.2.9]

I first suspected that this might have to do with environment variables since that's how I'm storing the database credentials, but ssh calls to ssh user@ip echo $DB_PASSWORD result in the expected value.

Pinwheeler
  • 1,061
  • 2
  • 13
  • 26

1 Answers1

0

Turns out, I was going about this the wrong way. There's a whole subsystem dedicated to launching service applications called systemd

Here are several links to help any future travelers get started

Pinwheeler
  • 1,061
  • 2
  • 13
  • 26