2
votes

I am trying the example given here. It uses google app engine, cloud engine and the pub/sub service to execute cron tasks on the GCE. It fairly simple to understand and execute. However I tried replacing the logger_sample_task.py code with my own code (give below). All it does is log a string to a log file. Note: The script runs on Google compute engine

import logging

logging.basicConfig(filename='testlog.log', level=logging.INFO)
logging.info('Hope this works')

However after the setup when I check if the cron task was run , the cron service has a status failed. cron status failed

I followed all the steps exactly as given (both with and without my custon script) but it still says cron job failed. Any reasons or ways to find out the reason for this failure?

App engine has this error in its log:

https://pubsub.googleapis.com/v1beta2/projects/dummy-project-1082/topics/test:publish?alt=json returned "One or more messages in the publish request is empty. Each message must contain either non-empty data, or at least one attribute.">

Update: Got rid of the app engine error by following the suggestions in this post

1
Not exactly sure where your code is running (app engine or compute) but, you do know that you have no write permission on the file system in app engine, don't you?konqi
Its running on compute engine. I do know I cant write to a file in app engineletsc
ah okay, that part was unclear to me.konqi
Ill add that to the question so that it avoids any confusion to othersletsc

1 Answers

1
votes

Fixed it.

The issue was in this script. Specifically in the publish_to_topic function in the line where the function is being declared: def publish_to_topic(topic, msg='', create=True):

This causes the app to publish empty messages to the pub/sub topic the gce application is listening on (which app engine complained about in error message I posted above)

Just change msg='' to msg='test'. And the cron job is a success.