Closed allinws closed 7 months ago
I can confirm that also running it from a regular docker-compose container I still get logging messages that are not related to the cronjob but happen to be in the STDOUT when the cron job executes.... Any idea on how to fix this?
scheduler_1 | time="2022-01-27T16:37:59Z" level=info msg=starting iteration=0 job.command="python3 /home/kontorshund/web/manage.py count_users" job.position=0 job.schedule="* * * * *" scheduler_1 | time="2022-01-27T16:38:00Z" level=info msg="Not using S3" channel=stdout iteration=0 job.command="python3 /home/kontorshund/web/manage.py count_users" job.position=0 job.schedule="* * * * *" scheduler_1 | time="2022-01-27T16:38:00Z" level=info msg="Using live email settings" channel=stdout iteration=0 job.command="python3 /home/kontorshund/web/manage.py count_users" job.position=0 job.schedule="* * * * *" scheduler_1 | time="2022-01-27T16:38:01Z" level=info msg="Number of advertisements: 14" channel=stdout iteration=0 job.command="python3 /home/kontorshund/web/manage.py count_users" job.position=0 job.schedule="* * * * *" scheduler_1 | time="2022-01-27T16:38:02Z" level=info msg="job succeeded" iteration=0 job.command="python3 /home/kontorshund/web/manage.py count_users" job.position=0 job.schedule="* * * * *"
Hi @allinws, supercronic isn't designed to run outside of a container or under a process manager. If you can provide a Dockerfile or container that exhibits the issue we might be able to examine how supervisor and Django are interacting with it.
Otherwise, our advice would be to run supercronic in its own container, since this is an anti-pattern.
I'm running supercronic with Django, Docker and Supervisord, it works fine, however it logs thing not related to the cronjob, for example it's logging different error messages (from dotenv for example) and a print "LOGIN" which I do inside my Django app:
q_cron | crontab | time="2022-01-25T13:04:00Z" level=info msg=" dotenv.read_dotenv()" channel=stderr iteration=0 job.command=/var/app/bin/staging/count_number_of_users.sh job.position=0 job.schedule="* * * * *" q_cron | crontab | time="2022-01-25T13:04:03Z" level=info msg=LOGIN channel=stdout iteration=0 job.command=/var/app/bin/staging/count_number_of_users.sh job.position=0 job.schedule="* * * * *" q_cron | crontab | time="2022-01-25T13:04:04Z" level=info msg="Number of users in the DB: 68" channel=stdout iteration=0 job.command=/var/app/bin/staging/count_number_of_users.sh job.position=0 job.schedule="* * * * *" q_cron | crontab | time="2022-01-25T13:04:05Z" level=info msg="job succeeded" iteration=0 job.command=/var/app/bin/staging/count_number_of_users.sh job.position=0 job.schedule="* * * * *"
This is the part of my Dockerfile where I install Supercronic