2011-04-14 36 views
2

我困住了一個愚蠢的問題。問題是:螞蟻奔跑蝙蝠文件,並繼續前進

我要開始一個專有的自制服務器。該服務器使用.bat文件啓動(我在Windows操作系統上)。

我已經寫了一個Ant目標:

  1. <exec /> start-stupid-server.bat
  2. <waitfor />服務器端口。

所以bat文件被執行時,服務器偵聽的端口。 Ant編寫BUILD SUCCESSFUL並且不退出。 Ant等待服務器窗口關閉。 我試過100,500種方法來克服它,但我沒有成功。 有沒有一種方法在螞蟻到<exec /> bat文件並忘記它?

<exec spawn="true" />沒有幫助,因爲螞蟻關閉服務器窗口和服務器關閉。

我已經試過<exec />有:

start start-stupid-server.bat, 
start /b start-stupid-server.bat 

沒有什麼幫助:(螞蟻仍在等待,直到服務器窗口關閉

這裏是我的目標:

<target name="start_proprietary_server" depends="bootstrap"> 
    <echo message="going to stop MDM server instance... "/> 
    <forget daemon="true"> 
     <exec executable="${app.custom.root}/bin/stopAll.bat" dir="${app.custom.root}/bin" /> 
    </forget> 
    <waitfor 
      maxwait="20" maxwaitunit="second" 
      checkevery="1" checkeveryunit="second" timeoutproperty="mdm.stop.error"> 
     <and> 
      <not> <socket server="localhost" port="12000" /> </not> 
      <not> <socket server="localhost" port="14444" /> </not> 
     </and> 
    </waitfor> 

    <if> 
     <isset property="mdm.stop.error" /> 
     <then> 
      <echo message="There are some problems while stopping MDM server. See what's went wrong" /> 
     </then> 
     <else> 
      <echo message="MDM server successfully stoped." /> 
     </else> 
    </if> 

    <echo message="going to start MDM server instance... "/> 

    <!-- 
     Starts but doesn't exit target 
     <exec executable="cmd" dir="${app.custom.root}/bin" > 
      <arg value="/c start startAll.bat" /> 
     </exec> 
    --> 

    <!-- 
     <forget daemon="true"> 
      <exec executable="cmd" dir="" > 
       <arg value="/c startAll.bat" /> 
      </exec> 
     </forget> 
    --> 

    <forget daemon="true"> 
     <exec executable="${app.custom.root}/bin/startAll.bat" dir="${app.custom.root}/bin" /> 
    </forget> 


    <echo message="Wating for localhost ports #12000 and #14444"/> 
    <waitfor 
      maxwait="40" maxwaitunit="second" 
      checkevery="3" checkeveryunit="second" timeoutproperty="mdm.start.error"> 
     <and> 
      <socket server="localhost" port="12000" /> 
      <socket server="localhost" port="14444" /> 
     </and> 
    </waitfor> 

    <if> 
     <isset property="mdm.start.error" /> 
     <then> 
      <echo message="There are some problems while starting MDM server. See what's went wrong" /> 
     </then> 
     <else> 
      <echo message="MDM server has been started." /> 
     </else> 
    </if> 
</target> 

這裏bat文件:

call .\bcmenv.bat 
start /min .\startLocator.bat 
sleep 5 

start /min .\startServices.bat 
exit 

我試着使用forget標籤給exec它,使用startstart /bcall,但沒有什麼幫助。在服務器窗口關閉之前,Ant不會完成任務。

如果我用菌種沒有forget,螞蟻退出目標時關閉服務器窗口。它與遺忘一起使用產卵,Ant目標沒有完成,直到服務器窗口關閉。

接下來我可以嘗試什麼?

+0

你能提供更多的信息嗎?也許看到你的批處理文件會有幫助。 – Brad 2011-04-14 15:14:44

+0

嗨布拉德。我已經添加了關於該問題的更多信息。我累了:忘記,彈幕,執行,電話,開始...沒有任何幫助。在專有的start_server.bat關閉之前,Ant不會完成目標。 – Sergey 2011-04-18 07:52:05

回答

0

可以使這將啓動服務器,並立即返回使用start命令另一個批處理文件:

start <path_to_server_bat> <args> 

你試過spawn=true