1

Let's say my custom runtime uses a container with a bash process in it.

#snippet
ADD crontab /etc/cron.d/zip-splitter
RUN crontab /etc/cron.d/zip-splitter
RUN chmod 0644 /etc/cron.d/zip-splitter

CMD ["/var/local/zip-splitter/entry.sh"]

In entry.sh I have:

#!/bin/bash
#
echo "Starting cron in the background"
cron -f -L 0  &

#
# Respond to liveness & readiness checks from AppEngine
#
echo "Starting gunicorn"
cd /var/local/zip-splitter && gunicorn -b :8080 main:app

Now the trouble I am having lies with the jobs scheduled by cron. How do I get stdout/stderr from said jobs to reach my GCP console logs ?

I have tried:

  1. using the Linux "logger" command by piping stdout & stderr
  2. directing stdout & stderr to "local files" in the container in /var/log
  3. using "gcloud logs" (couldn't get nice log lines)

Thanks in advance.

jldupont
  • 93,734
  • 56
  • 203
  • 318
  • Docs seem to indicate that `stdout`/`stderr` should by default be captured as [Runtime logs](https://cloud.google.com/logging/docs/view/service/appengine-logs#runtime_logs), so try not redirect them. Also [Custom logs](https://cloud.google.com/logging/docs/view/service/appengine-logs#custom_logs) may be of interest (but I didn't see exactly how to configure them). – Dan Cornilescu Mar 03 '18 at 14:03
  • @DanCornilescu Are you sure this covers also commands running through cron ? – jldupont Mar 03 '18 at 14:13
  • Not really, saw nothing in the logs docs specifically about cron. But the GAE cron service is simply issuing `GET` requests to your app, don't you see the corresponding logs just as request logs? Or are you using cron differently? (kinda suspecting this from your question) – Dan Cornilescu Mar 03 '18 at 14:19
  • @DanCornilescu Thanks for trying to help. I just want to point out I am using a custom runtime. – jldupont Mar 03 '18 at 14:59
  • Saw that. But if you're using standard GAE cron (i.e. via `cron.yaml`) it shouldn't make a difference. – Dan Cornilescu Mar 03 '18 at 16:10
  • @DanCornilescu Excellent point. I could get rid of the container cron daemon and leverage GAE's cron for this particular service in my application. Thanks for this perspective, I had my nose stuck on the tree. – jldupont Mar 03 '18 at 16:18

0 Answers0