2012-03-07 85 views
0

我想寫一個Ruby腳本來殺死我的本地主機上的數據庫服務器。通過Ruby連接到HSQL並關閉服務器

當我運行'ant hsql'它啓動數據庫(輸出如下),我必須保持該終端窗口打開。 構建文件:/Users/cparaiso/dev/src/testproject-src/build.xml

hsql: 

install-parent-pom: 
[artifact:install] [INFO] Installing /Users/cparaiso/dev/src/testproject-src/pom.xml to /Users/cparaiso/.m2/repository/org/jasig/portal/uportal-parent/4.0.3/uportal-parent-4.0.3.pom 
    [touch] Creating /var/folders/8v/1k2gkj412q1_8084x6lvtbqr0000gn/T/jasig/uportal-parent.pom-110044247-marker 
    [echo] Starting HSQL on 8887 
    [echo] Using: file:/Users/cparaiso/dev/src/testproject-src/data/uPortal 
    [java] [[email protected]]: [Thread[main,5,main]]: checkRunning(false) entered 
    [java] [[email protected]]: [Thread[main,5,main]]: checkRunning(false) exited 
    [java] [[email protected]]: Startup sequence initiated from main() method 
    [java] [[email protected]]: Could not load properties from file 
    [java] [[email protected]]: Using cli/default properties only 
    [java] [[email protected]]: Initiating startup sequence... 
    [java] [[email protected]]: Server socket opened successfully in 10 ms. 
    [java] [[email protected]]: Database [index=0, id=0, db=file:/Users/cparaiso/dev/src/testproject-src/data/uPortal, alias=uportal] opened sucessfully in 377 ms. 
    [java] [[email protected]]: Startup sequence completed in 388 ms. 
    [java] [[email protected]]: 2012-03-07 15:32:25.198 HSQLDB server 2.2.8 is online on port 8887 
    [java] [[email protected]]: To close normally, connect and execute SHUTDOWN SQL 
    [java] [[email protected]]: From command line, use [Ctrl]+[C] to abort abruptly 

我的問題是我怎麼能不關閉在Ruby中使用kill命令殺掉該進程的服務器?

如果我試圖通過kill命令殺死進程,我會得到'BUILD FAILED'並且它會卡住,直到我按下Ctrl + C鍵。這不是我想要的。有任何想法嗎? TIA

回答

1

我不知道如何在Ruby中發出SQL語句,但是如果連接到數據庫服務器併發出SQL語句SHUTDOWN,它將關閉服務器進程。