1、上传jar至服务器
将打包好的jar包上传,我这上传到/edu/service/user
2、使用java命令启动
1
|
java -jar edu-service-user.jar &
|
3、查看管控台
如上,OK启动成功了
自定义dubbo服务维护的shell脚本
脚本命名规范:/edu/service/xxx/service-xxx.sh
脚本命名,如:/edu/service/user/service-user.sh
效果:
cd /edu/service/user
./service-user.sh start
./service-user.sh stop
./service-user.sh restart
2.1 服务维护注意事项(结合自定义的Shell脚本)
(1)脚本规范 ----- 尽可能通用
(2)守护进程
(3)内存调优设置 ----按需调整
(4)日志处理 ------只保留应用Log4J输出的日志
(5)避免服务冲突 ------进程名、端口
(6)避免进程误杀 -----全匹配
2.2 给service-user.sh赋予可执行的权限
1
|
[root
@localhost
user]
# chmod a+x service-user.sh
|
2.3 执行
1
|
./service-user.sh start
|
2.4 shell代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/sh
## java env
export JAVA_HOME=/home/jdk1.7.0_71
export JRE_HOME=
$JAVA_HOME
/jre
## service name
APP_NAME=user
SERVICE_DIR=/edu/service/
$APP_NAME
SERVICE_NAME=edu-service-
$APP_NAME
JAR_NAME=
$SERVICE_NAME
\.jar
PID=
$SERVICE_NAME
\.pid
cd
$SERVICE_DIR
case
"$1"
in
start)
nohup
$JRE_HOME
/bin/java -Xms256m -Xmx512m -jar
$JAR_NAME
>/dev/null 2>&1 &
echo $! >
$SERVICE_DIR
/
$PID
echo
"=== start $SERVICE_NAME"
;;
stop)
kill
`cat
$SERVICE_DIR
/
$PID
`
rm -rf
$SERVICE_DIR
/
$PID
echo
"=== stop $SERVICE_NAME"
sleep
5
##
## edu-service-aa.jar
## edu-service-aa-bb.jar
P_ID=`ps -ef |
grep
-w
"$SERVICE_NAME"
|
grep
-v
"grep"
| awk
'{print $2}'
`
if
[
"$P_ID"
==
""
]; then
echo
"=== $SERVICE_NAME process not exists or stop success"
else
echo
"=== $SERVICE_NAME process pid is:$P_ID"
echo
"=== begin kill $SERVICE_NAME process, pid is:$P_ID"
kill
-9
$P_ID
fi
;;
restart)
$0 stop
sleep
2
$0 start
echo
"=== restart $SERVICE_NAME"
;;
*)
## restart
$0 stop
sleep
2
$0 start
;;
esac
exit
0
|
本文转自我爱大金子博客51CTO博客,原文链接http://blog.51cto.com/1754966750/1907398如需转载请自行联系原作者
我爱大金子