Sun Java System Application Server 9.1 管理指南

创建 Windows 服务

结合使用 Sun Java System Application Server 附带的 appservService.exeappserverAgentService.exe 可执行文件以及 Microsoft 提供的 Service Control 命令 (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" 命令。