简体   繁体   English

Google App Engine,Java:在开发服务器被杀死之前执行操作

[英]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.

相关问题 Google App Engine端点API开发服务器 - Google App Engine Endpoints API Dev Server 与Google App Engine开发服务器一起运行最新的Rails App时,java.security.AccessControlException - java.security.AccessControlException when running fresh Rails App with Google App Engine Dev Server Java 8上的Google App Engine - 开发时无法使用java.time。 服务器? - Google App Engine on Java 8 - java.time not available on dev. server? 在本地开发服务器上的存储桶中写入的Google App引擎Java API无法正常工作 - Google App engine Java API writte in bucket on local dev server doesn't work 如何让IntelliJ将Java7用于Google App Engine开发服务器? - How to get IntelliJ to use Java7 for Google App Engine dev server? Google App Engine开发服务器如何对数据存储存根? - How does Google App Engine Dev Server Stub the Datastore? Google App Engine开发服务器给出错误500(IntelliJ IDEA) - Google App Engine Dev Server Gives Error 500 (IntelliJ IDEA) 如何获取本地开发服务器中Google云存储上载文件的公共链接(Google App Engine + JAVA) - How to get public link for the uploaded file on google cloud storage in local dev server(Google App engine+JAVA) App Engine Java-重新启动后未保存Dev服务器数据存储 - App engine Java - Dev server datastore not saved after restart 具有Firebase和Google App引擎的Java服务器 - Java server with Firebase and Google App engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM