Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
b213960a
Commit
b213960a
authored
Jul 26, 2018
by
Junling Bu
Browse files
refactor[project]: 项目的部署方案重新设计。
parent
f1eb00ad
Changes
15
Hide whitespace changes
Inline
Side-by-side
deploy/.gitignore
View file @
b213960a
/litemall-admin-api/litemall-admin-api.jar
/litemall-os-api/litemall-os-api.jar
/litemall-wx-api/litemall-wx-api.jar
/litemall-admin/dist.tar
/litemall-admin/dist.tar
/litemall-db/litemall_schema.sql
/litemall-db/litemall_schema.sql
/litemall-db/litemall_table.sql
/litemall-db/litemall_table.sql
/litemall-db/litemall_data.sql
/litemall-db/litemall_data.sql
/litemall-api/litemall-admin-api.jar
/litemall-api/litemall-wx-api.jar
/litemall-api/litemall-os-api.jar
deploy/README.md
View file @
b213960a
1.
项目进一步打包到deploy文件夹中:
1.
项目进一步打包到deploy文件夹中:
*
litemall-os-api模块编译得到的litemall-os-api-0.1.0-exec.jar 保存到deploy的litemall-
os-
api文件夹中,同时重命名成litemall-os-api.jar
*
litemall-os-api模块编译得到的litemall-os-api-0.1.0-exec.jar 保存到deploy的litemall-api文件夹中,同时重命名成litemall-os-api.jar
*
litemall-wx-api模块编译得到的litemall-wx-api-0.1.0-exec.jar 保存到deploy的litemall-
wx-
api文件夹中,同时重命名成litemall-wx-api.jar
*
litemall-wx-api模块编译得到的litemall-wx-api-0.1.0-exec.jar 保存到deploy的litemall-api文件夹中,同时重命名成litemall-wx-api.jar
*
litemall-admin-api模块编译得到的litemall-admin-api-0.1.0-exec.jar 保存到deploy的litemall-
admin-
api文件夹中,同时重命名成litemall-admin-api.jar
*
litemall-admin-api模块编译得到的litemall-admin-api-0.1.0-exec.jar 保存到deploy的litemall-api文件夹中,同时重命名成litemall-admin-api.jar
*
litemall-admin模块编译以后,把dist文件夹压缩,然后放到deploy的litemall-admin文件夹中。
*
litemall-admin模块编译以后,把dist文件夹压缩,然后放到deploy的litemall-admin文件夹中。
*
litemall-db模块的sql文件拷贝到deploy的litemall-db文件夹中。
2.
使用FileZilla把deploy整个文件夹上传到云主机的/home/ubuntu文件夹中
2.
使用FileZilla把deploy整个文件夹上传到云主机的/home/ubuntu文件夹中
3.
使用PuTTY登录云主机
3.
使用PuTTY登录云主机
...
@@ -14,8 +15,9 @@
...
@@ -14,8 +15,9 @@
```bash
```bash
cd deploy
cd deploy
mysql -h localhost -u root -p123456
mysql -h localhost -u root -p123456
source ./litemall-db/litemall_schema.sql
source ./litemall-db/litemall_schema.sql
source ./litemall-db/litemall.sql
source ./litemall-db/litemall_table.sql
source ./litemall-db/litemall_data.sql
```
```
注意,123456是开发者所设置的MySQL管理员密码
注意,123456是开发者所设置的MySQL管理员密码
警告:
警告:
...
@@ -41,10 +43,10 @@
...
@@ -41,10 +43,10 @@
7.
部署脚本
7.
部署脚本
为了简化步骤1和步骤2,完成了deploy/util/
upload
.sh上传脚本和deploy/util/lazy.sh部署脚本,
为了简化步骤1和步骤2,完成了deploy/util/
package
.sh上传脚本和deploy/util/lazy.sh部署脚本,
注意:
注意:
> * 开发者需要在deploy/util/
upload
.sh和deploy/util/lazy.sh中设置相应的云主机登录账号和密钥文件路径。
> * 开发者需要在deploy/util/
package
.sh和deploy/util/lazy.sh中设置相应的云主机登录账号和密钥文件路径。
> * 开发者需要在deploy/util/reset.sh设置云主机的MySQL的root登录账户。
> * 开发者需要在deploy/util/reset.sh设置云主机的MySQL的root登录账户。
> * 请先执行上述1-6步骤,确保部署环境成功。
> * 请先执行上述1-6步骤,确保部署环境成功。
...
...
deploy/bin/deploy.sh
View file @
b213960a
...
@@ -10,23 +10,22 @@ cd /home/ubuntu/deploy/litemall-admin
...
@@ -10,23 +10,22 @@ cd /home/ubuntu/deploy/litemall-admin
rm
-rf
dist
rm
-rf
dist
mkdir
dist
mkdir
dist
tar
-zxvf
dist.tar
-C
dist
tar
-zxvf
dist.tar
-C
dist
cd
.
#部署三个Spring Boot应用
#部署三个Spring Boot应用
#如果服务已经启动,则尝试停止
#如果服务已经启动,则尝试停止
sudo
/etc/init.d/
litemall-os-api stop
sudo
service
litemall-os-api stop
sudo
/etc/init.d/
litemall-wx-api stop
sudo
service
litemall-wx-api stop
sudo
/etc/init.d/
litemall-admin-api stop
sudo
service
litemall-admin-api stop
#部署Spring Boot应用成服务
#部署Spring Boot应用成服务
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-
os-
api/litemall-os-api.jar /etc/init.d/litemall-os-api
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-api/litemall-os-api.jar /etc/init.d/litemall-os-api
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-
wx-
api/litemall-wx-api.jar /etc/init.d/litemall-wx-api
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-api/litemall-wx-api.jar /etc/init.d/litemall-wx-api
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-
admin-
api/litemall-admin-api.jar /etc/init.d/litemall-admin-api
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-api/litemall-admin-api.jar /etc/init.d/litemall-admin-api
#启动服务
#启动服务
sudo
/etc/init.d/
litemall-os-api restart
sudo
service
litemall-os-api restart
sudo
/etc/init.d/
litemall-wx-api restart
sudo
service
litemall-wx-api restart
sudo
/etc/init.d/
litemall-admin-api restart
sudo
service
litemall-admin-api restart
# 如果静态文件是通过tomcat来服务,则tomcat8服务最好也再启动
# 如果静态文件是通过tomcat来服务,则tomcat8服务最好也再启动
#sudo service tomcat8 stop
#sudo service tomcat8 stop
...
...
deploy/bin/reset.sh
View file @
b213960a
...
@@ -26,7 +26,7 @@ mysql -h localhost -u $ROOT -p$PASSWORD < db.sql
...
@@ -26,7 +26,7 @@ mysql -h localhost -u $ROOT -p$PASSWORD < db.sql
rm
db.sql
rm
db.sql
# 删除storage文件夹内文件
# 删除storage文件夹内文件
cd
/home/ubuntu/deploy/litemall-
os-
api/storage
cd
/home/ubuntu/deploy/litemall-api/storage
rm
-f
./
**
rm
-f
./
**
# 重新部署服务
# 重新部署服务
...
...
deploy/litemall-admin-api/litemall-admin-api.conf
deleted
100644 → 0
View file @
f1eb00ad
RUN_ARGS
=--
spring
.
profiles
.
active
=
dep
JAVA_OPTS
=
\ No newline at end of file
deploy/litemall-api/README.md
0 → 100644
View file @
b213960a
开发者需要注意的是
litemall-os-api.jar、litemall-wx-api.jar和litemall-admin-api.jar三个模块内部
已经有默认的开发配置文件,但是这些配置文件可能仅仅适用于开发阶段。
为了应用部署阶段时期的配置文件,开发者可以在config文件夹里面的同名配置文件中
采用新的配置信息。
例如litemall.notify.mail.enable在开发litemall-core模块内部resources/application-core.yml
中设置的是false,而这里config/application-core.yml中设置的是true,项目部署启动时则会先
读取config/application-core.yml中的true值。
\ No newline at end of file
deploy/litemall-api/config/application-admin.yml
0 → 100644
View file @
b213960a
deploy/litemall-api/config/application-core.yml
0 → 100644
View file @
b213960a
litemall
:
notify
:
mail
:
# 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员
enable
:
true
host
:
smtp.exmail.qq.com
username
:
ex@ex.com.cn
password
:
XXXXXXXXXXXXX
sendfrom
:
ex@ex.com.cn
sendto
:
ex@qq.com
# 短消息模版通知配置
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
sms
:
enable
:
true
appid
:
111111111
appkey
:
xxxxxxxxxxxxxx
template
:
-
name
:
paySucceed
templateId
:
156349
-
name
:
captcha
templateId
:
156433
-
name
:
ship
templateId
:
158002
-
name
:
refund
templateId
:
159447
# 微信模版通知配置
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
wx
:
enable
:
true
template
:
-
name
:
paySucceed
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
name
:
captcha
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
name
:
ship
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
name
:
refund
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 快鸟物流查询配置
express
:
enable
:
true
appId
:
"
XXXXXXXXX"
appKey
:
"
XXXXXXXXXXXXXXXXXXXXXXXXX"
vendors
:
-
code
:
"
ZTO"
name
:
"
中通快递"
-
code
:
"
YTO"
name
:
"
圆通速递"
-
code
:
"
YD"
name
:
"
韵达速递"
-
code
:
"
YZPY"
name
:
"
邮政快递包裹"
-
code
:
"
EMS"
name
:
"
EMS"
-
code
:
"
DBL"
name
:
"
德邦快递"
-
code
:
"
FAST"
name
:
"
快捷快递"
-
code
:
"
ZJS"
name
:
"
宅急送"
-
code
:
"
TNT"
name
:
"
TNT快递"
-
code
:
"
UPS"
name
:
"
UPS"
-
code
:
"
DHL"
name
:
"
DHL"
-
code
:
"
FEDEX"
name
:
"
FEDEX联邦(国内件)"
-
code
:
"
FEDEX_GJ"
name
:
"
FEDEX联邦(国际件)"
\ No newline at end of file
deploy/litemall-api/config/application-db.yml
0 → 100644
View file @
b213960a
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
supportMethodsArguments
:
true
params
:
count=countSql
spring
:
datasource
:
druid
:
url
:
jdbc:mysql://localhost:3306/litemall?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&verifyServerCertificate=false&useSSL=false
driver-class-name
:
com.mysql.jdbc.Driver
username
:
litemall
password
:
litemall123456
initial-size
:
10
max-active
:
50
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
validation-query
:
SELECT 1 FROM DUAL
test-on-borrow
:
false
test-on-return
:
false
test-while-idle
:
true
time-between-eviction-runs-millis
:
60000
filters
:
stat,wall,log4j
deploy/litemall-api/config/application-os.yml
0 → 100644
View file @
b213960a
deploy/litemall-api/config/application-wx.yml
0 → 100644
View file @
b213960a
# 开发者应该设置成自己的wx相关信息
litemall
:
wx
:
app-id
:
wxa5b486c6b918ecfb
app-secret
:
e04004829d4c383b4db7769d88dfbca1
mch-id
:
111111
mch-key
:
xxxxxx
notify-url
:
http://www.example.com/wx/order/pay-notify
\ No newline at end of file
deploy/litemall-os-api/litemall-os-api.conf
deleted
100644 → 0
View file @
f1eb00ad
RUN_ARGS
=--
spring
.
profiles
.
active
=
dep
JAVA_OPTS
=
\ No newline at end of file
deploy/litemall-wx-api/litemall-wx-api.conf
deleted
100644 → 0
View file @
f1eb00ad
RUN_ARGS
=--
spring
.
profiles
.
active
=
dep
JAVA_OPTS
=
\ No newline at end of file
deploy/util/lazy.sh
View file @
b213960a
#!/bin/bash
#!/bin/bash
# 本脚本的作用是
# 本脚本的作用是
# 1. 编译打包Spring Boot应用
# 1. 项目打包
# 2. 编译litemall-admin应用
# 2. 上传云主机
# 3. 调用upload.sh上传
# 3. 远程登录云主机并执行deploy脚本
# 4. ssh远程登录云主机,运行deploy/bin/deploy.sh脚本
# 注意:运行脚本必须是在litemall主目录下,类似如下命令
# cd litemall
# ./deploy/util/lazy.sh
# 请设置云主机的IP地址和账户
# 请设置云主机的IP地址和账户
# 例如 ubuntu@122.152.206.172
# 例如 ubuntu@122.152.206.172
...
@@ -29,20 +24,17 @@ then
...
@@ -29,20 +24,17 @@ then
exit
-1
exit
-1
fi
fi
echo
$PWD
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
>
/dev/null
&&
pwd
)
"
mvn clean
cd
$DIR
/../..
mvn package
LITEMALL_HOME
=
$PWD
echo
"LITEMALL_HOME
$LITEMALL_HOME
"
cd
./litemall-admin
# 项目打包
# 安装阿里node镜像工具
cd
$LITEMALL_HOME
npm
install
-g
cnpm
--registry
=
https://registry.npm.taobao.org
./deploy/util/package.sh
# 安装node项目依赖环境
cnpm
install
cnpm run build:dep
cd
..
# 上传云主机
echo
$PWD
scp
-i
$ID_RSA
-r
./deploy
$REMOTE
:/home/ubuntu/
./deploy/util/upload.sh
# 远程登录云主机并执行deploy脚本
# 远程登录云主机并执行deploy脚本
ssh
$REMOTE
-i
$ID_RSA
<<
eeooff
ssh
$REMOTE
-i
$ID_RSA
<<
eeooff
...
...
deploy/util/
upload
.sh
→
deploy/util/
package
.sh
View file @
b213960a
#!/bin/bash
#!/bin/bash
# 请注意
# 请注意
#
1.
本脚本的作用是把本项目编译的结果保存到deploy文件夹中
,然后上传到云主机
# 本脚本的作用是把本项目编译的结果保存到deploy文件夹中
#
2
.
运行本脚本前,请确认Spring Boot模块已经编译,同时litemall-admin模块也已经便宜
#
1
.
把项目数据库文件拷贝到litemall-db
#
3
.
util/upload.sh脚本是运行在开发机中,bin/deploy.sh脚本是运行在云主机中
#
2
.
编译litemall-admin,然后打包到litemall-admin
#
4
.
这是一个简单的脚本,开发者可以按照自己需求修改
#
3
.
编译后台服务模块,然后拷贝到litemall-api
# 请设置云主机登录IP地址和账户
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
>
/dev/null
&&
pwd
)
"
# 例如 ubuntu@122.152.206.172
cd
$DIR
/../..
REMOTE
=
LITEMALL_HOME
=
$PWD
# 请设置本地SSH私钥文件id_rsa路径
echo
"LITEMALL_HOME
$LITEMALL_HOME
"
# 例如 /home/litemall/id_rsa
ID_RSA
=
if
test
-z
"
$REMOTE
"
then
echo
"请设置云主机登录IP地址和账户"
exit
-1
fi
if
test
-z
"
$ID_RSA
"
then
echo
"请设置云主机登录IP地址和账户"
exit
-1
fi
# 复制三个Spring Boot应用
# 需要注意的是target目录里面存在两种jar,一种是当前模块纯编译代码的jar,另外一种是包含依赖库的可执行jar,
# 这里我们需要的是可执行jar
cp
-f
./litemall-os-api/target/litemall-os-api-
*
-exec
.jar ./deploy/litemall-os-api/litemall-os-api.jar
cp
-f
./litemall-wx-api/target/litemall-wx-api-
*
-exec
.jar ./deploy/litemall-wx-api/litemall-wx-api.jar
cp
-f
./litemall-admin-api/target/litemall-admin-api-
*
-exec
.jar ./deploy/litemall-admin-api/litemall-admin-api.jar
# 压缩litemall-admin应用
tar
-zcvf
./deploy/litemall-admin/dist.tar
-C
./litemall-admin/dist
.
# 复制数据库
# 复制数据库
cp
-f
./litemall-db/sql/litemall_schema.sql ./deploy/litemall-db/litemall_schema.sql
cp
-f
./litemall-db/sql/litemall_schema.sql ./deploy/litemall-db/litemall_schema.sql
cp
-f
./litemall-db/sql/litemall_table.sql ./deploy/litemall-db/litemall_table.sql
cp
-f
./litemall-db/sql/litemall_table.sql ./deploy/litemall-db/litemall_table.sql
cp
-f
./litemall-db/sql/litemall_data.sql ./deploy/litemall-db/litemall_data.sql
cp
-f
./litemall-db/sql/litemall_data.sql ./deploy/litemall-db/litemall_data.sql
# 上传云主机
cd
./litemall-admin
scp
-i
$ID_RSA
-r
./deploy
$REMOTE
:/home/ubuntu/
# 安装阿里node镜像工具
npm
install
-g
cnpm
--registry
=
https://registry.npm.taobao.org
# 安装node项目依赖环境
cnpm
install
cnpm run build:dep
cd
..
# 压缩litemall-admin应用
tar
-zcvf
./deploy/litemall-admin/dist.tar
-C
./litemall-admin/dist
.
# 复制三个Spring Boot应用
# 需要注意的是target目录里面存在两种jar,一种是当前模块纯编译代码的jar,另外一种是包含依赖库的可执行jar,
# 这里我们需要的是可执行jar
mvn clean
mvn package
cp
-f
./litemall-os-api/target/litemall-os-api-
*
-exec
.jar ./deploy/litemall-api/litemall-os-api.jar
cp
-f
./litemall-wx-api/target/litemall-wx-api-
*
-exec
.jar ./deploy/litemall-api/litemall-wx-api.jar
cp
-f
./litemall-admin-api/target/litemall-admin-api-
*
-exec
.jar ./deploy/litemall-api/litemall-admin-api.jar
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment