File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,27 +45,11 @@ jobs:
4545 username : ${{ secrets.EC2_USER }}
4646 key : ${{ secrets.EC2_SSH_KEY }}
4747 script : |
48- echo "Stopping existing application if running..."
49- if pgrep -f "java -jar"; then
50- pkill -f "java -jar"
51- sleep 5
52- fi
53-
54- echo "Finding latest JAR..."
55- JAR_PATH=$(ls -t /home/ubuntu/app/build/libs/*.jar | head -n 1)
56- echo "Using JAR: $JAR_PATH"
57-
58- echo "Export DB environment variable..."
59- export DB_PASSWORD='${{ secrets.DB_PASSWORD }}'
48+ cd /home/ubuntu/app
6049
61- echo "Starting application..."
62- nohup java -jar "$JAR_PATH" \
63- > /home/ubuntu/app/app.log 2>&1 &
50+ pkill -f "java -jar" || true
6451
65- sleep 3
66- if pgrep -f "java -jar"; then
67- echo "Application started successfully."
68- else
69- echo "Application failed to start."
70- exit 1
71- fi
52+ JAR_PATH=$(ls -t build/libs/*.jar | head -n 1)
53+
54+ nohup DB_PASSWORD='${{ secrets.DB_PASSWORD }}' \
55+ java -jar "$JAR_PATH" > app.log 2>&1 &
You can’t perform that action at this time.
0 commit comments