我无法在Cloudify 2.7.1中使用axternal脚本进行startDetection。
我试试:
def result = ServiceUtils.isPortOccupied(port)
println "startDetection.groovy: is service started : ${result}"
return result
结果是:
2014-09-25 12:46:09,268 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: isPortFree port ...
2014-09-25 12:46:09,300 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: is service started : false
2014-09-25 12:46:09,316 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Command exited with value: 0
2014-09-25 12:46:09,517 default.service [1] INFO [org.cloudifysource.usm.UniversalServiceManagerBean] - Process liveness test passed
在开始脚本的真正结束之前。
我试试:
def result = ServiceUtils.isPortOccupied(port)
println "startDetection.groovy: is service started : ${result}"
if (result){
System.exit(0)
}
System.exit(-1)
并且开始脚本结束前的结果是:
2014-09-25 12:59:19,299 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: isPortFree port ...
2014-09-25 12:59:19,331 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: is service started : false
2014-09-25 12:59:19,359 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Command exited with value: 255
2014-09-25 12:59:19,360 default.service [1] SEVERE [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Event lifecycle external process exited with abnormal status code: 255
2014-09-25 12:59:19,361 default.service [1] SEVERE [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Event lifecycle external process failed: /root/gigaspaces/tools/groovy/bin/groovy: 60: [: GNU/Linux: unexpected operator /root/gigaspaces/tools/groovy/bin/groovy: 100: [: GNU/Linux: unexpected operator startDetection.groovy: isPortFree port ... startDetection.groovy: is service started : false
2014-09-25 12:59:19,362 default.service [1] SEVERE [org.cloudifysource.usm.dsl.DSLEntryExecutor] - Failed to execute entry: startDetection.groovy; Caused by: org.cloudifysource.usm.USMException: Event lifecycle external process exited with abnormal status code: 255 /root/gigaspaces/tools/groovy/bin/groovy: 60: [: GNU/Linux: unexpected operator /root/gigaspaces/tools/groovy/bin/groovy: 100: [: GNU/Linux: unexpected operator startDetection.groovy: isPortFree port ... startDetection.groovy: is service started : false
at org.cloudifysource.usm.launcher.DefaultProcessLauncher.launchProcess(DefaultProcessLauncher.java:762)
at org.cloudifysource.usm.launcher.DefaultProcessLauncher.launchProcess(DefaultProcessLauncher.java:1086)
at org.cloudifysource.usm.dsl.DSLEntryExecutor.run(DSLEntryExecutor.java:90)
at org.cloudifysource.usm.dsl.DSLBeanConfiguration$6.isProcessAlive(DSLBeanConfiguration.java:529)
at org.cloudifysource.usm.USMLifecycleBean.isProcessLivenessTestPassed(USMLifecycleBean.java:736)
at org.cloudifysource.usm.UniversalServiceManagerBean.launch(UniversalServiceManagerBean.java:1140)
at org.cloudifysource.usm.UniversalServiceManagerBean.installAndRun(UniversalServiceManagerBean.java:834)
at org.cloudifysource.usm.UniversalServiceManagerBean.access$000(UniversalServiceManagerBean.java:103)
at org.cloudifysource.usm.UniversalServiceManagerBean$2$1.run(UniversalServiceManagerBean.java:807)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-09-25 12:59:19,362 default.zabbix [1] WARNING [org.cloudifysource.usm.dsl.DSLBeanConfiguration] - Liveness Detector failed to execute. Exception was: org.cloudifysource.usm.USMException: Event lifecycle external process exited with abnormal status code: 255
并且启动脚本结束后的结果是:
2014-09-25 12:46:09,268 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: isPortFree port ...
2014-09-25 12:46:09,300 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: is service started : false
2014-09-25 12:46:09,316 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Command exited with value: 0
2014-09-25 12:46:09,517 default.service [1] INFO [org.cloudifysource.usm.UniversalServiceManagerBean] - Process liveness test passed
在这两种情况下它都不起作用。
我只能在闭包中使用startDetection:
startDetection {
println "service.groovy(startDetection): isPortFree ${port} ..."
return ServiceUtils.isPortOccupied(port)
}
喜欢stopDetection。
有人知道为什么吗?
答案 0 :(得分:0)
您上面复制的日志条目似乎没问题。通过启动检测,如果您使用外部生命周期脚本,您所能做的就是传递一个指示通过/失败的进程返回代码。零返回码表示测试通过 - 开始检测成功完成。非零值表示测试未通过。
在您的问题中,当启动脚本成功完成时,您会得到: 过程活跃度测试已通过
所以脚本正确完成,开始检测通过。什么是不起作用的?