forked from YunaiV/ruoyi-vue-pro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-prod.sh
More file actions
49 lines (36 loc) · 1.19 KB
/
deploy-prod.sh
File metadata and controls
49 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Script to deploy somle-esb service
SERVICE_NAME="yudao"
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
JAR_PATH=$(ls /opt/module/${SERVICE_NAME}/yudao-server/target/*.jar | head -n 1)
# Function to create or overwrite the service file
create_service_file() {
cat <<EOL > "$SERVICE_FILE"
[Unit]
Description=$SERVICE_NAME
After=network.target
[Service]
User=root
ExecStart=/usr/bin/java -jar $JAR_PATH --server.port=55002 --spring.profiles.active=prod
Restart=always
[Install]
WantedBy=multi-user.target
EOL
echo "$(date) - Service file created at $SERVICE_FILE"
}
# Function to deploy the service
deploy_service() {
echo "$(date) - Reloading systemd manager configuration..."
systemctl daemon-reload
echo "$(date) - Enabling $SERVICE_NAME service..."
systemctl enable $SERVICE_NAME
echo "$(date) - Restarting $SERVICE_NAME service..."
systemctl restart $SERVICE_NAME
echo "$(date) - $SERVICE_NAME service deployed and started successfully."
}
# Main execution
echo "$(date) - Creating the service file..."
create_service_file
echo "$(date) - Deploying the $SERVICE_NAME service..."
deploy_service
echo "$(date) - Deployment script completed."