构建&部署
构建
通过命令行进入到mfish-nocode根目录,执行以下命令
bash
mvn clean
mvn package
提示
命令执行完成后会在mfish-nocode项目的mf-xxxx/target目录下,生成war/jar包文件
不同模块版本会生成在各mf-xxxx模块下target文件夹中
部署
1、jar部署方式
使用命令行执行:
bash
java –jar mf-xxxx.jar
2、war部署方式
pom.xml中的packaging修改为war,放入tomcat服务器webapps
xml
<packaging>war</packaging>
提示
不同模块版本在mfish-nocode/mf-xxxx模块下修改pom.xml
SpringBoot去除内嵌Tomcat(PS:此步骤不重要,因为不排除也能在容器中部署war)
xml
<!-- 排除内置tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
后端启动脚本
提示
在服务目录下执行
bash
#启动
./start.sh start
#停止
./start.sh stop
#重启
./start.sh restart
start.sh脚本如下:
注意
脚本只适用于单机部署,集群部署脚本请自行编写
bash
#!/bin/sh
if [ -z "$1" ];then
echo "输入参数 start restart stop"
exit
fi
if [ "$1" = "start" ]
then
gateway=`ps -ef | grep mf-gateway.jar | grep -v grep | awk '{print $2}'`
if [ -n "$gateway" ]
then
echo "gateway进程已存在"
else
echo "启动网关服务"
nohup /usr/java/bin/java -jar mf-gateway.jar --server.port=11116 >/dev/null 2>&1 &
fi
oauth=`ps -ef | grep mf-oauth.jar | grep -v grep | awk '{print $2}'`
if [ -n "$oauth" ]
then
echo "oauth进程已存在"
else
echo "启动认证中心"
nohup /usr/java/bin/java -jar mf-oauth.jar >/dev/null 2>&1 &
fi
sys=`ps -ef | grep mf-sys.jar | grep -v grep | awk '{print $2}'`
if [ -n "$sys" ]
then
echo "sys进程已存在"
else
echo "启动系统服务"
nohup /usr/java/bin/java -jar mf-sys.jar >/dev/null 2>&1 &
fi
codecreate=`ps -ef | grep mf-code-create.jar | grep -v grep | awk '{print $2}'`
if [ -n "$codecreate" ]
then
echo "code-create进程已存在"
else
echo "启动代码生成中心"
nohup /usr/java/bin/java -jar mf-code-create.jar >/dev/null 2>&1 &
fi
storage=`ps -ef | grep mf-storage.jar | grep -v grep | awk '{print $2}'`
if [ -n "$storage" ]
then
echo "storage进程已存在"
else
echo "启动文件缓存中心"
nohup /usr/java/bin/java -jar mf-storage.jar >/dev/null 2>&1 &
fi
monitor=`ps -ef | grep mf-monitor.jar | grep -v grep | awk '{print $2}'`
if [ -n "$monitor" ]
then
echo "monitor进程已存在"
else
echo "启动监控中心"
nohup /usr/java/bin/java -jar mf-monitor.jar --server.port=11121 >/dev/null 2>&1 &
fi
openai=`ps -ef | grep mf-openai.jar | grep -v grep | awk '{print $2}'`
if [ -n "$openai" ]
then
echo "openai进程已存在"
else
echo "启动聊天机器人"
nohup /usr/java/bin/java -jar mf-openai.jar >/dev/null 2>&1 &
fi
scheduler=`ps -ef | grep mf-scheduler.jar | grep -v grep | awk '{print $2}'`
if [ -n "$scheduler" ]
then
echo "scheduler进程已存在"
else
echo "启动调度中心"
nohup /usr/java/bin/java -jar mf-scheduler.jar >/dev/null 2>&1 &
fi
sleep 3
echo "查询进程..."
ps -ef|grep mf-
elif [ "$1" = "restart" ]
then
pkill -f mf-gateway.jar
pkill -f mf-oauth.jar
pkill -f mf-sys.jar
pkill -f mf-code-create.jar
pkill -f mf-storage.jar
pkill -f mf-monitor.jar
pkill -f mf-openai.jar
pkill -f mf-scheduler.jar
sleep 3
echo "查询进程..."
ps -ef|grep mf-
echo "开始启动..."
nohup /usr/java/bin/java -jar mf-gateway.jar --server.port=11116 >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-oauth.jar >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-sys.jar >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-code-create.jar >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-storage.jar >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-monitor.jar --server.port=11121 >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-openai.jar >/dev/null 2>&1 &
nohup /usr/java/bin/java -jar mf-scheduler.jar >/dev/null 2>&1 &
sleep 3
echo "查询进程..."
ps -ef|grep mf-
elif [ "$1" = "stop" ]
then
pkill -f mf-gateway.jar
pkill -f mf-oauth.jar
pkill -f mf-sys.jar
pkill -f mf-code-create.jar
pkill -f mf-storage.jar
pkill -f mf-monitor.jar
pkill -f mf-openai.jar
pkill -f mf-scheduler.jar
sleep 3
echo "查询进程..."
ps -ef|grep mf-
else
echo "输入参数start restart stop"
fi
exit
nginx配置
bash
server {
listen 11119;
server_name localhost;
location / {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
root /app/mfish/mfish-nocode-view;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /api/ {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:11116/;
}
}
提示
root /app/mfish/mfish-nocode-view; (PS:前端打包文件路径)
proxy_pass http://127.0.0.1:11116/; (PS:后端网关地址,如果不在同一个服务器下修改为具体服务器地址)
nginx可以采用keepalive方式进行集群部署