简体   繁体   中英

Google compute engine example

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 状态失败

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM