2014-09-25 28 views
0

我無法使用Cloudify 2.7.1中的startDetection使用axternal腳本。startDetection外部腳本在Cloudify 2.7.1中不起作用

我嘗試:

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

謝謝你的快速回答巴拉克。 我認爲由於日誌顯示的錯誤:255個 嚴重事件生命週期的外部進程失敗: 嚴重事件生命週期的外部進程異常狀態碼退出... 嚴重無法執行條目:startDetection.groovy;由於:org.cloudifysource.usm.USMException:事件生命週期外部進程退出異常狀態代碼:255 ...意外的操作員startDetection.groovy ... – Victor 2014-09-29 11:35:57

+0

是的,日誌嚴重性在這裏誤導。但該操作似乎正常工作。順便說一句,你可能想看看Cloudify 3,因爲Cloudify 2.X即將結束生命。 – Barak 2014-09-29 12:51:59