-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a ping-cronjob to keep instance alive.
Use a cron-job to prevent the AppEngine instance from going to sleep. This should keep requests quick since the JVM is not being restarted often on new requests and all caches stay intact. This addresses issue #1.
- Loading branch information
1 parent
8fda430
commit 4d2cd56
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
appengine/src/main/java/org/retrostore/request/PingRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
<cronentries> | ||
<cron> | ||
<url>/ping</url> | ||
<description>Keep-alive for the AppEngine instance.</description> | ||
<schedule>every 1 minutes</schedule> | ||
</cron> | ||
</cronentries> |