Sun Java System Application Server 9.1 管理指南

在 Microsoft Windows 平台上自动重新启动

要在 Microsoft Windows 上自动重新启动,请创建一个 Windows 服务,并防止该服务在用户注销时关闭。

创建 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" 命令。

防止服务在用户注销时关闭

默认情况下,Java VM 从 Windows 捕捉指示操作系统正在关闭或者用户正在注销的信号,并关闭自身而不报告任何错误。此行为可导致 Application Server 服务在用户从 Windows 注销时关闭。要防止服务在用户注销时关闭,请设置 -Xrs Java VM 选项

要设置 -Xrs Java VM 选项,请将以下行添加到 as-install\domains\domain-name\config\domain.xml 文件中定义 Java VM 选项的部分:

<jvm-options>-Xrs</jvm-options>

如果 Application Server 服务正在运行,请先停止再重新启动该服务以使更改生效。


注 –

在某些 Windows 2003 Server 安装中,将 -Xrs 选项添加到 domain.xml 文件无法防止服务关闭。在这种情况下,请在 as-install\lib\processLauncher.xml 文件中添加该选项,如下所示:

<process name="as-service-name">
   ...
   <sysproperty key="-Xrs"/>
   ...