如何将Play Framework 2.0应用程序作为Windows服务运行?
我有一个要在Windows Server 2008 R2上部署(生产)的Play Framework 2.0应用程序.如何使其作为服务运行?
I have a Play Framework 2.0 application that I want to deploy (production) on Windows Server 2008 R2. How do I get it to run as a service?
这在Windows 7上对我有用:
This worked for me on Windows 7:
- 创建文件夹C:\ my_app
-
转到您的游戏!命令行中输入app文件夹,然后键入
- Create folder C:\my_app
Go to your Play! app folder in command line and type
play dist
在C:\ my_app \ something-SNAPSHOT \中创建一个新文件start.bat,并用以下命令填充该文件:
In C:\my_app\something-SNAPSHOT\ make a new file start.bat and fill it with command like this:
java -cp "C:\my_app\something-SNAPSHOT\lib\*" play.core.server.NettyServer
保存并启动start.bat.您的Play应用必须启动并正常运行.看一下服务器的PID.您将在下一步中使用它.
Save it and launch start.bat. Your play app must start and work as usual. Take a look at server's PID. You will use it in the next step.
现在使用命令提示符转到C:\ my_app \ yajsw \ bat并键入
Now using command prompt go to C:\my_app\yajsw\bat and type
genConfig.bat < PID from previous step >
您生成了C:\ my_app \ yajsw \ conf \ wrapper.conf.编辑此文件并按如下所示更改这些参数:
You generated C:\my_app\yajsw\conf\wrapper.conf. Edit this file and change these params like so:
wrapper.ntservice.name=My App Name
wrapper.ntservice.displayname=My App Name
保存文件.
wrapper.ntservice.name=My App Name
wrapper.ntservice.displayname=My App Name
Save file.
终止在6中启动的 start.bat 脚本,然后在C:\ my_app \ yajsw \ bat启动
Terminate the start.bat script you started in 6. then, in C:\my_app\yajsw\bat launch
runConsole.bat
如果应用启动,请执行Ctrl c
(并回答 y )以终止批处理文件,然后继续下一步.
runConsole.bat
If app starts, do a Ctrl c
(and answer y) to terminate the batch file and proceed to next step.
要安装服务启动(以管理员身份运行)
installService.bat
开始服务启动
startService.bat
现在,您可以在Windows服务中看到我的应用程序名称"服务.
要停止服务,您可以使用stopService.bat
.要卸载它uninstallService.bat
.
Now you can see your "My App Name" service in Windows services.
To stop service you can use stopService.bat
. To uninstall it uninstallService.bat
.