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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.