我已经构建了自定义服务。在调用exec之前,我正在执行一些预先任务(安装驱动程序,启动数据库和其他守护程序服务等)。此服务已成功启动。
Duing从Cloudera Manager停止,随着exec启动服务我想停止在pre任务中启动的服务。为此。我编写了一个脚本来停止所有的守护进程服务
但我发现只有以exec启动的服务才会停止在前任务中。
请指导我,如何解决问题。
我的service.sdl如下
{
"name" : "MYAPP",
"label" : "Myapp",
"description" : "My App Custom CSD",
"version" : "2.1",
"runAs" : {
"user" : "root",
"group" : "root"
},
"maxInstances" : 1,
"icon" : "images/myapp.png",
"parcel" : {
"repoUrl" : "http://54.12.197.150:8111/latest/",
"requiredTags" : [ "myapp" ]
},
"roles" : [
{
"name" : "MY_WEBSERVER",
"label" : "My Web Server",
"pluralLabel" : "My Web Server",
"startRunner" :
{
"program" : "scripts/control.sh",
"args" : [ "start" ]
},
"stopRunner" :
{
"relevantRoleTypes" : ["MY_WEBSERVER"],
"runner" :
{
"program" : "scripts/control.sh",
"args" : ["stop"]
},
"timeout" : 180000,
"masterRole" : "MY_WEBSERVER"
},
"topology" :
{
"minInstances" : "1",
"maxInstances" : "1"
},
"logging" :
{
"dir" : "/var/log/myapp-2.1/",
"filename" : "myapp.log"
}
}
]
}
和我的control.sh如下 -
#!/bin/bash
CMD=$1
case $CMD in
(start)
echo "Starting the MyAPP Service"
cp -r /opt/cloudera/parcels/myapp-2.1 /opt/
chmod 777 -R /opt/myapp-2.1/
sh /opt/myapp-2.1/resource/scripts/installer/MainScript
exec python -m SimpleHTTPServer 8080
;;
(stop)
sh /opt/myapp-2.1/resource/scripts/installer/StopAll
;;
(restart)
sh /opt/myapp-2.1/resource/scripts/installer/RestartAll
;;
(*)
echo "Don't understand [$CMD]"
;;
esac