0
votes

I configured my cron.xml and backends.xml to be run on google app engine as following :

cron.xml

<cronentries>
    <cron>
        <url>/_ah/start</url>
        <schedule>every 5 minutes</schedule>
        <target>updatebackend</target>
    </cron>
</cronentries>

backends.xml

<backends>
    <backend name="updatebackend">
        <class>B1</class>
        <options>
            <dynamic>true</dynamic>
            <public>false</public>
        </options>
    </backend>
</backends>

Then on my web.xml file I wrote like following :

web.xml

  <servlet>
    <servlet-name>update</servlet-name>
    <servlet-class>com.test.UpdateBackendServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>update</servlet-name>
    <url-pattern>/_ah/start</url-pattern>
  </servlet-mapping>

  <security-constraint>
    <web-resource-collection>
        <web-resource-name>mybackend</web-resource-name>
        <url-pattern>/_ah/start</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
  </security-constraint>

But when I deploy and run it on the google app engine, it always run twice. And my questions are :

  1. How can I make another url-pattern besides /_ah/start?
  2. How can I make it only run one time?

Thanks.

1

1 Answers

0
votes

Actually, you cannot use /_ah/start as a handler for your requests - it is reserved for the purpose of starting a backend instance. You should use a different handler. For example:

<url>/update</url>
<url-pattern>/update</url-pattern>

Now, when you call /update, App Engine will either use an existing backend instance, or it will automatically issue /_ah/start to start a new instance. You don't need to call /_ah/start yourself, unless you want to start your instance before any other request is sent to it.