1

I recently implemented a clock process in my heroku app (Python) to scrape data into a database for me every X hours. In the script, I have a line that is supposed to send me an email when the scraping begins and again when it ends. Today was the first day that it was supposed to run at 8AM UTC, and it seems to have ran perfectly fine as the data on my site has been updated.

However, I didn't receive any emails from the scraper, so I was trying to find the logs for that specific dyno to see if it hinted at why the email wasn't sent. However I am unable to see anything that even shows the process ran this morning.

With the below command all I see is that the dyno process is up as of my last Heroku deploy. But there is nothing that seems to suggest it ran successfully today... even though I know it did.

heroku logs --tail --dyno clock

yields the following output, which corresponds to the last time I deployed my app to heroku.

2021-04-10T19:25:54.411972+00:00 heroku[clock.1]: State changed from up to starting
2021-04-10T19:25:55.283661+00:00 heroku[clock.1]: Stopping all processes with SIGTERM
2021-04-10T19:25:55.402083+00:00 heroku[clock.1]: Process exited with status 143
2021-04-10T19:26:07.132470+00:00 heroku[clock.1]: Starting process with command `python clock.py --log-file -`
2021-04-10T19:26:07.859629+00:00 heroku[clock.1]: State changed from starting to up

My question is, is there any command or place to check on Heroku to see any output from my logs? For example any exceptions that were thrown? If I had any PRINT statements in my clock-process, where would those be printed to?

Thanks!

Hektar
  • 71
  • 7

1 Answers1

0

Although this is not the full answer, from the Ruby gem 'ruby-clock', we get an insight from the developer

Because STDOUT does not flush until a certain amount of data has gone into it, you might not immediately see the ruby-clock startup message or job output if viewing logs in a deployed environment such as Heroku where the logs are redirected to another process or file. To change this behavior and have logs flush immediately, add $stdout.sync = true to the top of your Clockfile.

So I'm guessing that it has something to do with flushing STDOUT when logging although I am not sure how to do that in Python.

I did a quick search and found this stackoverflow post

Namely

In Python 3, print can take an optional flush argument:

    print("Hello, World!", flush=True)

In Python 2, after calling print, do:

    import sys
    sys.stdout.flush()
marcus.salinas
  • 627
  • 4
  • 8