Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web startup message goes to stderr? #96

Open
andrewplummer opened this issue Jul 17, 2024 · 0 comments
Open

Web startup message goes to stderr? #96

andrewplummer opened this issue Jul 17, 2024 · 0 comments

Comments

@andrewplummer
Copy link

  • Yet Another Cron version: 0.19.0
  • Python version: 3.9.19

Description

Apologies in advance as I feel like I'm misunderstanding something here but no matter what I try the initial web message:

INFO:yacron:web: started listening on http://127.0.0.1:8080

Always seems to go to stderr. This causes false positives in the logs (using GCP in our case).

Dockerfile:

# Use an appropriate base image
FROM python:3.9-slim

RUN pip install yacron pyyaml

# Copy your yacron configuration file into the container
COPY . .

# Copy the entrypoint script into the container
COPY entrypoint.sh /root/entrypoint.sh
RUN chmod +x /root/entrypoint.sh

# Set the working directory
WORKDIR .

# Set the entrypoint to the script
ENTRYPOINT ["/bin/sh", "-c", "/usr/local/bin/yacron -c test.yml 2>err.txt"]

and config:

web:
  listen:
    - http://127.0.0.1:8080
    - unix:///tmp/yacron.sock

defaults:
  shell: /bin/bash

  concurrencyPolicy: Allow
  # Allow (default): allows concurrently running jobs
  # Forbid: forbids concurrent runs, skipping next run if previous hasn’t finished yet
  # Replace: cancels currently running job and replaces it with a new one

  failsWhen:
    producesStdout: false
    producesStderr: true
    nonzeroReturn: true

  onPermanentFailure:
    report:
      sentry:
        dsn:
          value:
        extra:
          foo: bar
          zbr: 123
        level: warning
      mail:
        from: [email protected]
        to: [email protected]
        smtpHost: 127.0.0.1
        smtpPort: 10025
        subject: Cron job '{{name}}' {% if success %}completed{% else %}failed{% endif %}
        body: |
          {{stderr}}

          (exit code: {{exit_code}})

  environment:
    - key: FOO
      value: foo
    - key: BAR
      value: bar

  statsd:
    host: localhost
    port: 8125
    prefix: my.cron.jobs.prefix.test01

logging:
  version: 1
  disable_existing_loggers: false
  formatters:
    simple:
      format: '%(asctime)s [%(processName)s/%(threadName)s] %(levelname)s (%(name)s): %(message)s'
  handlers:
    console:
      class: logging.StreamHandler
      level: DEBUG
      formatter: simple
      stream: ext://sys.stdout
  root:
    level: INFO
    handlers:
      - console
  loggers:
    yacron:
      level: INFO
      handlers:
        - console
      propagate: false

With this config as a test the err.txt should contain the initial startup message. Despite claiming INFO it seems that it was sent to stderr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant