播放2.0-服务器重新启动后作为Windows服务启动 [英] Play 2.0 - starting as Windows service after server restart

查看:96
本文介绍了播放2.0-服务器重新启动后作为Windows服务启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我玩了!作为Windows服务运行的应用程序.它是根据指南实施的.

I have the Play! application running as a windows service. It is implemented according to this guidance.

问题在于,重新启动服务器后,应用程序的根文件夹中的RUNNING_PID不会被删除,并且应用程序无法再次启动.我必须删除此文件,然后手动再次启动该服务.

The problem is that the RUNNING_PID at the root folder of the application is not removed when the server is restarted and the application cannot start again. I have to remove this file and start the service again manually.

有解决方案吗?

推荐答案

YAJSW

对于YAJSW,我发现此答案有了更好的理解.当然,它与您提供的链接非常相​​似,无论如何,请记住,更建议使用dist命令而不是stage,因为它吸引了更多开发人员注意(更多错误已在dist中修复).而且米哈伊尔的答案更清楚了(投票给他!)

YAJSW

In case of YAJSW I found this answer with better understanding. It's of course pretty similar to link you gave, anyway keep in mind that it's more often advised to use dist command instead of stage as it has got better developers attention (more bugs fixed in dist). And Mikhail's answer is just clearer (vote him up!)

RUNNING_PID的情况下,有一些拉取请求建议添加一个禁用pidfile的选项...无论如何,正如我所看到的,它们仍然没有被接受...

In case of RUNNING_PID, there was some pull requests which suggested to add an option of disabling pidfile... anyway as I can see, none of them was accepted still...

实际上,如果您无法避免创建它,则可以...在应用程序启动后立即将其删除,最好使用全局对象的 onStart()方法.要随时了解工作实例的当前PID,只需将文件重命名为某种东西,启动时Play不会检查该文件-例如RUNNING_PID_INFO.在这种情况下,服务器的重启服务将毫无问题地运行您的应用程序.

Actually if you can't avoid creating it, you can... remove it right after application's start, preferably with Globals object's onStart() method. To stay informed what is current PID of the working instance, just rename the file to something, which won't be checked by Play at the startup - for an example RUNNING_PID_INFO. In such case after server's restart service will run your application without problems.

import play.GlobalSettings;
import java.io.File;

public class Global extends GlobalSettings {
    @Override
    public void onStart(Application application) {
        File pidFile = new File("RUNNING_PID");
        pidFile.renameTo(new File("RUNNING_PID_INFO"));
    }

    @Override
    public void onStop(Application application) {
        File pidFile = new File("RUNNING_PID_INFO");
        pidFile.delete();
    }
}

(注意:在apllication.conf中更改pidfile.path不会解决问题,因为游戏会将其用于检查实例是否正常工作).

(note: changing pidfile.path in apllication.conf will NOT solve the problem, as play will use that for checking if instance is working).

这篇关于播放2.0-服务器重新启动后作为Windows服务启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆