gdrt
gdrt

Reputation: 3315

Can't create cron job in Google App Engine app that has multiple services

When I deploy my application which has multiple services, I can't see the cron job to be registered in App Engine Console, despite following directory hierarchy described in Configuration files overview .

This is my cron.xml file, which I placed in my default service's WEB-INF directory:

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
    <cron>
        <url>/cron</url>
        <description>Execute scheduled tasks</description>
        <schedule>every 5 minutes</schedule>
    </cron>
</cronentries>

This is my default service's appengine-web.xml file:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>default</application>
  <version>1</version>
  <threadsafe>true</threadsafe>

  <sessions-enabled>true</sessions-enabled>

  <manual-scaling>
    <instances>1</instances>
  </manual-scaling>
</appengine-web-app>

My GAE application has 4 services, all defined in application.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
  <display-name>modules-ear</display-name>
  <module>
    <web>
      <web-uri>module-default-1.0</web-uri>
      <context-root>module-default</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>module-1-1.0</web-uri>
      <context-root>module-1</context-root>
    </web>
  </module>
  <!-- declared other modules likewise -->
  <library-directory>lib</library-directory>
</application>

My project structure:

This is my project structure

Can you please tell me what am I doing wrong that my cron job doesn't run?

Upvotes: 0

Views: 797

Answers (1)

Sidharta Noleto
Sidharta Noleto

Reputation: 71

Try deploying cron configuration in a separate command:

  1. If you're using gcloud cli: gcloud app deploy cron.yaml
  2. Or gradle appengine plugin: ./gradlew appengineUpdateCron
  3. Or maven appengine plugin: mvn appengine:update_cron

I had the same problem and running the command after the deployment solved it!

Upvotes: 1

Related Questions