[英]google app engine, java: perform action before dev server is killed
I am killing my Google App Engine dev server with kill
. 我正在使用
kill
杀死我的Google App Engine开发服务器。 I would like to clean up some local changes before the server dies. 我想在服务器死机前清理一些本地更改。 How can I do it?
我该怎么做?
To kill dev server you can simply press control-c
as the docs state: 要杀死开发服务器,您只需在文档状态下按
control-c
即可:
To stop the web server, press Control-C (on Windows, Mac or Linux).
Control-c is in Unix systems sends the SIGINT signal, which you can achieve manually via kill -SIGINT <pid>
. Control-c在Unix系统中发送SIGINT信号,您可以通过
kill -SIGINT <pid>
手动实现。
This should gracefully shutdown the server - in this case you can install a lifecycle listener to get called when server shuts down. 这应该可以正常关闭服务器-在这种情况下,您可以安装生命周期侦听器以在服务器关闭时被调用。 Just implement the
contextDestroyed(..)
method as shown in this example and register it in your web.xml
. 只需实现本示例中所示的
contextDestroyed(..)
方法,然后将其注册到web.xml
。
NOTE: such shutdown hook does NOT work on production server (verified). 注意:这样的关闭挂钩在生产服务器(已验证)上不起作用。 I never tried it on dev server, but it should work as this is plain Jetty.
我从未在开发服务器上尝试过它,但是它应该可以正常工作,因为这是普通的Jetty。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.