Sun Java System Application Server 9.1 管理指南

建立 Windows 服務

將 Sun Java System Application Server 隨附的 appservService.exeappserverAgentService.exe 可執行檔與 Microsoft 提供的服務控制指令 (sc.exe) 配合使用。

sc.exe 指令隨附於 Windows XP,並位於 Windows 安裝目錄的 system32 子目錄 (通常為 C:\windows\system32C:\winnt\system32) 中。編寫本文件時,已可以從 ftp://ftp.microsoft.com/reskit/win2000/sc.zip 下載 Windows 2000 sc.exe。如需有關使用 sc.exe 的更多資訊,請參閱 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndllpro/html/msdn_scmslite.asp

使用 appservService.exeappservAgentService.exe,如下所示:

C:\winnt\system32\sc.exe create service-name binPath= \"fully-qualified-path-to-appservService.exe 
\"fully-qualified-path-to-asadmin.bat start-command\" 
\"fully-qualified-path-to-asadmin.bat stop-command\"" 
start= auto DisplayName= "display-name"

備註 –

binpath 與等號 (=) 之間沒有空格。等號之後與路徑之前必須有空格。


例如,若要建立可以啟動和停止網域 domain1 的名為 SunJavaSystemAppServer DOMAIN1 的服務,請使用密碼檔案 C:\Sun\AppServer\password.txt

C:\windows\system32\sc.exe create domain1 binPath= 
"C:\Sun\AppServer\lib\appservService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
start-domain --user admin --passwordfile C:\Sun\AppServer\password.txt domain1\" 
\"C:\Sun\AppServer\bin\asadmin.bat stop-domain domain1\"" start= auto 
DisplayName= "SunJavaSystemAppServer DOMAIN1"

若要建立可以啟動和停止節點代理程式 agent1 的服務,請使用:

C:\windows\system32\sc.exe create agent1 binPath= 
"C:\Sun\AppServer\lib\appservAgentService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
start-node-agent --user admin --passwordfile C:\Sun\AppServer\password.txt agent1\" 
\"C:\Sun\AppServer\bin\asadmin.bat stop-node-agent agent1\"" start= auto 
DisplayName= "SunJavaSystemAppServer AGENT1"

備註 –

做為 binPath= 參數的一部分而輸入的啟動和停止指令必須具有正確的語法。請在指令提示符號下執行這些指令以進行測試。如果指令無法正確啟動或停止網域或節點代理程式,則說明該服務無法正常工作。



備註 –

請勿將服務與 asadmin startstop 指令混合使用來進行啟動和停止。否則,將導致伺服器狀態不同步。例如,即使元件沒有執行,該服務可能也會顯示已啟動元件。為避免發生這種情況,請在使用服務時始終使用 sc.exe 指令啟動和停止元件。


如果 sc.exe create 指令並未正確地建立服務,請刪除服務後再試一次。若要刪除服務,請使用 sc.exe delete "service-name" 指令。