Alibaba Cloud Toolkit one-click deployment of remote running practice

When I was studying Arthas some time ago, I seemed to have seen applications related to the Alibaba Cloud Toolkit plug-in from some materials. When I was exploring one-click deployment knowledge this time, some materials mentioned it again, so I simply explored it. Little by little, I tried to deploy my blog project to a test environment with one click.​ 

 1.Basic introduction

Alibaba Cloud Toolkit is a plug-in based on Eclipse/IDEA, designed to help developers deploy and manage applications on Alibaba Cloud more conveniently. It supports multiple languages ​​and frameworks, such as Java, Python, NodeJS, Spring Boot, Django, etc., making it very developer-friendly. So one-click deployment is just one of the many functions it provides. Higher-end functions also include application observation, hot deployment, etc. There are many functions. After all, the entire plug-in installation package is 120M in size. I only fumbled for a day, trying to deploy the daily deployment test of the application at work to the test environment. I also practiced the deployment of my blog program, so I have some small experiences, so I used the little remote deployment I have mastered to do it. A simple share.

The remote in the remote deployment practiced this time refers to other servers in the same intranet environment, not servers in the cloud (although it can also be supported). The following implementation methods are remote deployment implementations seen in work:

(1) Maven plug-in: It can be packaged with one click and automatically deployed to the remote server. It is integrated in the pom.xml of the project and exists as part of the code configuration.

(2) Jenkins is a popular open source continuous integration and delivery tool that can be used to automatically build, test and deploy software projects. It is independent of the external existence of the project and can be easily applied to enterprise-level team applications.

(3) Run on, which comes with the new version of IDEA, can deploy remote applications with one click. It is more focused on developer applications. It has the necessity of its existence. There is a separate article on this site to introduce it.

(4) Alibaba Cloud Toolkit plug-in, the protagonist of this practice.

2. Plug-in usage

(1) The installation of the plug-in is skipped directly. The plug-in is already installed by default. At the same time, the corresponding project is also imported into IDEA. A new "one-click deployment" running configuration is added directly to the location where the program is running. Refer to the figure below. Show:

Create a new one-click deployment.gif

(New one-click deployment)

1、Deployment.jpg

(Configure Deployment)

2、Advanced.jpg

(Configure Advanced)

3.Details

(1) The deployment process and the pre- and post-deployment needs to be personalized based on the actual project situation, and also depend on different packaging methods. This example is to upload all the files in the chendd-admin directory in the target directory to Server, the following is my packaged folder directory structure:

3. Project packaging directory.jpg

(2) The maven packaging command in this example distinguishes the test environment. The packaged files are all configured files from the test environment. The reference command is "-DskipTests=true clean package -P test". See the picture reference for configuring Deployment. This command No need for mvn;

(3) Generally, when packaging, it is necessary to determine whether it is the first time to package, or whether the folders previously packaged and deployed exist. If they exist, some folders need to be deleted. Usually, if some files exist, they will be overwritten, and if they do not exist, they will be added. That's it, but if some third-party jar files are upgraded, they need to be deleted first and then added. Therefore, in this configuration, Before deploy provides the conf, lib-jar, lib-local, and lib-project directories. deletion operation;

(4) One-click deployment is named "admin-test-8888", which means that the test environment of the admin project is packaged, and the running port number is 8888;

(5) The location of one-click deployment is "/app/admin-test-8888/", the full path is "/app/admin-test-8888/chendd-admin/", and it is convenient to cooperate with the startup script Manage the start and stop of the project, so when the script file is used to determine whether the deployed project program is running, the name "admin-test-8888" is used as the identification condition keyword. If the keyword is found from the process, It means that the server is starting, otherwise it means that it has not started, so the name of the program directory deployed on each server is required to be unique. The management script `startup-dir.sh` can be found in another article on this site "Spring Boot project startup script practice》;

(6) The combined reference of deployment pre-script and running script is as follows:

# 前置脚本
if [ -d "/app/admin-test-8888/chendd-admin" ];then
      rm -rf /app/admin-test-8888/chendd-admin/conf/;
      rm -rf /app/admin-test-8888/chendd-admin/lib-jar/;
      rm -rf /app/admin-test-8888/chendd-admin/lib-local/;
      rm -rf /app/admin-test-8888/chendd-admin/lib-project/;
      echo "清空文件夹 /app/admin-test-8888/";
fi
 
# 启动脚本
cd chendd-admin/bin;
sh startup-dir.sh restart;

(7) The startup script includes 120 seconds of log monitoring, so after the startup command is completed, there is no separate log monitoring script added;

4. Deployment process

One-click deployment.gif

(Lite)

(1) The full version of the picture is 3M in size, please download it yourself if you are interested;

(2) The plug-in has relatively powerful functions, and I have only explored one of its functions this time. There should be other related articles in the future;

(3) One-click deployment needs to be combined with actual scenarios when applying, such as: directory structure of project packaging, start-stop scripts for managing projects, etc., to provide a more elegant start-stop management script;

(4) Relevant downloads can be directed to the original text:

Alibaba Cloud Toolkit one-click deployment of remote operation practiceWelcome to Chen Dongdong’s personal experience sharing platformicon-default.png?t=N7T8https://www.chendd. cn/blog/article/1719684142542442498.html

Guess you like

Origin blog.csdn.net/haiyangyiba/article/details/134177262