0

我无法在 Cloudify 2.7.1 中为 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。

有人知道为什么吗?

4

1 回答 1

0

您在上面复制的日志条目似乎没问题。使用启动检测,如果您使用外部生命周期脚本,您所能做的就是传递一个指示通过/失败的进程返回代码。零返回代码表示测试通过 - 启动检测成功完成。非零值表示测试未通过。

在您的问题中,当启动脚本成功完成时,您会得到以下信息: Process liveness test pass

所以脚本正确完成,启动检测通过。究竟是什么不起作用?

于 2014-09-28T10:33:56.627 回答