This article presents best practices for writing commands when deploying applications using the ** Alibaba Cloud Toolkit ** plugin.
This article provides best practices for writing commands when deploying the following applications using the Alibaba Cloud Toolkit (https://cn.aliyun.com/product/cloudtoolkit_en) plugin.
--Standard Java Web Tomcat application --Standard Java Fatjar application --Standard Spring Boot application --Standard Go application
Suppose / root / tomcat /
on your Linux system is the root directory of your Tomcat application, as shown above. You need to deploy the Java web application WAR package (javademo.war) in this / root / tomcat / webapps
directory.
The corresponding command configuration is as follows.
sh /root/sh/restart-tomcat.sh
The contents of the restart-tomcat.sh script are as follows.
source /etc/profile
killall java
rm -rf /root/tomcat/webapps/javademo
sh /root/tomcat/bin/startup.sh
The / ect / profile file is used to set environment variables and contains the following:
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export JAVA_HOME=/usr/share/jdk1.8.0_14
export PATH=$JAVA_HOME/bin:.....
Suppose the / root / javademo
directory on your Linux system is used as the root directory for your Java application. You need to deploy the Java application jar package to the / root / javademo
directory.
The corresponding command settings are as follows.
sh /root/sh/restart-java.sh
The contents of the restart-java.sh script are as follows.
source /etc/profile
killall java
nohup java -jar /root/javademo/javademo-0.0.1-SNAPSHOT.jar > nohup.log 2>&1 &
Suppose your Linux system's / root / springbootdemo
directory is used as the root directory for your Spring Boot application. Deploy the Spring Boot application jar package (springbootdemo-0.0.1-SNAPSHOT.jar) to the / root / springbootdemo
directory.
The corresponding command settings are as follows.
sh /root/sh/restart-springboot.sh
The contents of the restart-springboot.sh script are as follows.
source /etc/profile
killall java
nohup java -jar /root/springbootdemo/springbootdemo-0.0.1-SNAPSHOT.jar > nohup.log 2>&1 &
Suppose the / root / godemo
directory on your Linux system is used as the root directory for your Go application. You need to deploy the Go application executable (godemo) to the / root / godemo
directory.
The corresponding command configuration is as follows.
sh /root/sh/restart-go.sh
The contents of the restart-go.sh script are as follows.
source /etc/profile
pkill -f 'godemo'
chmod 755 /root/godemo/godemo;
sh -c /root/godemo/godemo
Recommended Posts