I re-wrote and re-enabled the custom warmup servlet recently, and found it really works like charming

57 views
Skip to first unread message

Tapir

unread,
Mar 25, 2012, 7:31:10 PM3/25/12
to Google App Engine
Sorry, maybe I didn't get it before. But I really think the docs for
custom warmup servlet is not perfect.

The new code:

public void service(ServletRequest req, ServletResponse resp)
throws ServletException, IOException {
try {
URL url = new URL("/about?from=warmup");
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/
octet-stream");

DataOutputStream outSteam = new DataOutputStream (new
BufferedOutputStream (connection.getOutputStream()));

byte[] keyBytes = "warmup".getBytes ("UTF-8");
outSteam.write (keyBytes, 0, keyBytes.length);
outSteam.flush ();
outSteam.close ();

connection.getResponseCode();
} catch (Exception e) {
}
}

And the old code:

public void service(ServletRequest req, ServletResponse resp)
throws ServletException, IOException {
try {
Queue queue = QueueFactory.getDefaultQueue();
queue.add(TaskOptions.Builder.withUrl("/
about").param("from", "warmup").method(Method.GET));
} catch (Exception e) {
}
}

Jeff Schnitzer

unread,
Mar 26, 2012, 12:10:21 AM3/26/12
to google-a...@googlegroups.com
This seems a very roundabout approach. Why not just use
/about?from=warmup as the warmup url?

FWIW, I don't think there is any ambiguity in the docs. When the
warmup request returns, GAE thinks your app is initialized. If you
spawn a task to make the actual work asynchronous, of course that
isn't going to work!

Jeff

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>

Reply all
Reply to author
Forward
0 new messages