diff --git a/appengine/src/main/java/org/retrostore/MainServlet.java b/appengine/src/main/java/org/retrostore/MainServlet.java index 3974d0a..6926687 100644 --- a/appengine/src/main/java/org/retrostore/MainServlet.java +++ b/appengine/src/main/java/org/retrostore/MainServlet.java @@ -43,6 +43,7 @@ import org.retrostore.request.FaviconRequest; import org.retrostore.request.ImportRpkRequest; import org.retrostore.request.LoginRequest; +import org.retrostore.request.PingRequest; import org.retrostore.request.PolymerRequest; import org.retrostore.request.PublicSiteRequest; import org.retrostore.request.ReportAppRequest; @@ -114,6 +115,7 @@ static class Modules { private static List createRequests(Modules m) { return ImmutableList.of(new FaviconRequest(m.defaultResourceLoader), + new PingRequest(), new PublicSiteRequest(m.defaultResourceLoader), new ReportAppRequest(m.defaultResourceLoader, m.appManagement, m.imgServWrapper, m.mailService), diff --git a/appengine/src/main/java/org/retrostore/request/PingRequest.java b/appengine/src/main/java/org/retrostore/request/PingRequest.java new file mode 100644 index 0000000..c2c72be --- /dev/null +++ b/appengine/src/main/java/org/retrostore/request/PingRequest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2018, Sascha Häberling + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.retrostore.request; + +import org.retrostore.data.user.UserService; + +/** + * We use ping requests to check that the AppEngine instance is alive. This is the class that + * handles these requests. + */ +public class PingRequest implements Request { + private static final String PATH_SERVE = "/ping"; + + @Override + public boolean serveUrl(RequestData requestData, Responder responder, UserService userService) { + if (!PATH_SERVE.equals(requestData.getUrl())) { + return false; + } + responder.respond("OK", Responder.ContentType.PLAIN); + return true; + } +} diff --git a/appengine/src/main/webapp/WEB-INF/cron.xml b/appengine/src/main/webapp/WEB-INF/cron.xml new file mode 100644 index 0000000..b1eabd6 --- /dev/null +++ b/appengine/src/main/webapp/WEB-INF/cron.xml @@ -0,0 +1,24 @@ + + + + + + /ping + Keep-alive for the AppEngine instance. + every 1 minutes + + \ No newline at end of file