如何将 Play Framework 2.0 应用程序作为 Windows 服务运行? [英] How do I run a Play Framework 2.0 application as a Windows service?
问题描述
我有一个 Play Framework 2.0 应用程序,我想在 Windows Server 2008 R2 上部署(生产).如何让它作为服务运行?
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
播放区
在 C:my_appsomething-SNAPSHOT 中创建一个新文件 start.bat 并用如下命令填充它:
In C:my_appsomething-SNAPSHOT make a new file start.bat and fill it with command like this:
java -cp "C:my_appsomething-SNAPSHOTlib*" play.core.server.NettyServer
保存并启动 start.bat.您的播放应用程序必须像往常一样启动和工作.查看服务器的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_appyajswat 并输入
Now using command prompt go to C:my_appyajswat and type
genConfig.bat <上一步的PID>
您生成了 C:my_appyajswconfwrapper.conf.编辑此文件并像这样更改这些参数:
You generated C:my_appyajswconfwrapper.conf. Edit this file and change these params like so:
wrapper.ntservice.name=我的应用名称
wrapper.ntservice.displayname=我的应用程序名称
保存文件.
wrapper.ntservice.name=My App Name
wrapper.ntservice.displayname=My App Name
Save file.
终止您在 6 中启动的 start.bat 脚本.然后,在 C:my_appyajswat 中启动
Terminate the start.bat script you started in 6. then, in C:my_appyajswat 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
.
这篇关于如何将 Play Framework 2.0 应用程序作为 Windows 服务运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!