Alibaba Cloud Toolkit uses

Today circle of friends turned to see an article in Alibaba's official IDE plug----- Cloud Toolkit, looked at, I feel very Niubi, took two hours to pro-test, really easy to use.

The official description is:  Cloud Toolkit is a local IDE plug-ins to help developers to more efficiently develop, test, diagnose and deploy applications. Through plug-ins, local can apply one-click deployment to any server, and even the clouds (ECS, EDAS, Kubernetes and applets clouds, etc.); and also built Arthas diagnosis, Dubbo tool, Terminal terminal, file upload and MySQL implementation of tools such as .

The following is a testing process.

        Development Tools: idea (2018.1.1 above)

        JDK: 1.8 or later

        Deployment: Maven build (not supported Gradle)

1, based on Spring Boot quickly build a Web, the project is structured as follows:

2, installation Alibaba Cloud Toolkit plug-in

        This step refer to the official document:  https://help.aliyun.com/document_detail/98762.html

3, start the server configuration parameters After installing

Inside the red frame corresponding to the menu functions are as follows:

I tested is deployed to any server that Deploy to Host, as follows, first configure the server,

Click on the upper right corner Add Host, the following pop-up box, fill in the server-related parameters, save it.

4, the path of the server configuration items as well as some of the scripts to be executed.

The following are project-related documents, demo-0.0.1.jar is a jar package, restart.sh script to restart the services, start.sh script to start the service, shutdown.sh script is out of service, nohup.out is log output file

As operation, to deploy the project on the server, the box will pop up, the associated configuration:

Jar package configuration and execution of the script to be following the path to an absolute path

Command above configuration is as follows:

sh /opt/test-cloud-toolkit/restart.sh demo-0.0.1.jar

解释为: 项目部署后执行restart.sh脚本,这个脚本的作用是重启服务。后面的demo-0.0.1.jar是一个参数传入脚本文件中。

restart.sh脚本内容如下:

#!/bin/sh
#服务名
if [ ! -n "$1" ] ;then
	echo "please input a process name!"
	exit
else
	process_name=$1
	echo "process name is $process_name!"
	PID=$(ps -ef | grep $process_name | grep -v "$0" | grep -v "grep" | awk '{print $2}')
	if [[ -z $PID ]]; then
		nohup java -jar ./$process_name &
		if [ $? -eq 0 ];then
			echo "start $process_name success"
			tail -f nohup.out
			exit
		else
			echo "start $process_name fail"
		fi
	else
		echo "$process_name process id:$PID"
	fi
	kill $PID
	if [ $? -eq 0 ];then
		echo "kill $process_name success"
		sleep 5
		nohup java -jar ./$process_name &
		if [ $? -eq 0 ];then
			echo "start $process_name success"
		else
			echo "start $process_name fail"
		fi
	else
		echo "kill $process_name fail"
	fi
fi
tail -f nohup.out

以上配置好以后,点击如下按钮即可启动部署

执行结果:

这样即部署成功!浏览器请求一下:

可见部署成功!

我们可以修改一下名称,避免同一项目需要多处部署以免混淆:

修改完后如下:

然后再次部署时只需要点击绿色三角按钮即可!

将sayHello方法的输出修改一下,再次测试:

访问浏览器:

到此结束!

自动部署之前项目使用过jenkins,这次简单测试后,感觉Cloud Toolkit相比jenkins有如下优点:

1、配置简单,不用单独安装jenkins(占磁盘空间)

2、修改代码后不需要上传到git就可以实现本地打包部署,而jenkins必须是代码上传到git仓库后才可以被打包到

发布了34 篇原创文章 · 获赞 43 · 访问量 4万+

Guess you like

Origin blog.csdn.net/pavel101/article/details/100995413
Recommended