Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Moura <[email protected]>
  • Loading branch information
phsmoura committed Oct 14, 2024
1 parent c175e13 commit 20b3be4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ RUN dnf update -y && \
COPY pluto pluto
COPY httpd.conf /etc/httpd/conf/

RUN mkdir -p /etc/fedora-messaging /etc/pki/fedora-messaging /var/log/pluto && \
RUN mkdir -p /etc/fedora-messaging /etc/pki/fedora-messaging /var/log/planet && \
sed -i 's/Listen 80$/Listen 8080/g' /etc/httpd/conf/httpd.conf && \
chgrp -R 0 /run/httpd /var/www/html /pluto /etc/fedora-messaging && \
chmod -R g+rwX /etc/httpd /var/log/httpd /var/log/pluto /run/httpd /var/www/html /pluto /etc/fedora-messaging && \
chmod +x /pluto/build_planet.py
chmod -R g+rwX /etc/httpd /var/log/httpd /var/log/planet /run/httpd /var/www/html /pluto /etc/fedora-messaging && \
chmod +x /pluto/build_planet.py /pluto/start.sh

WORKDIR /pluto
RUN bundle install

EXPOSE 8080

ENTRYPOINT ["/usr/sbin/httpd"]
CMD ["-D","FOREGROUND","-f","/etc/httpd/conf/httpd.conf"]
ENTRYPOINT ["/pluto/start.sh"]
10 changes: 1 addition & 9 deletions pluto/build_planet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

logger = logging.getLogger(__name__)
logging.basicConfig(
filename=f"/var/log/pluto/{today}.log",
filename=f"/var/log/planet/build.log",
encoding="utf-8",
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s",
Expand Down Expand Up @@ -172,11 +172,3 @@
api.publish(api.Message(topic=f"planet.build", body={"Users": planet_users}))
except Exception as e:
logger.error(f"Error when trying to publish message: {e}")

tail_command = [
"tail",
"-qf",
"/etc/httpd/logs/access_log",
"/etc/httpd/logs/error_log",
]
tail_process = subprocess.Popen(tail_command)
5 changes: 5 additions & 0 deletions pluto/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

truncate --size=0 /etc/httpd/logs/access_log /etc/httpd/logs/error_log /var/log/planet/build.log
tail -qf /etc/httpd/logs/access_log /etc/httpd/logs/error_log /var/log/planet/build.log &
exec /usr/sbin/httpd -D FOREGROUND -f /etc/httpd/conf/httpd.conf

0 comments on commit 20b3be4

Please sign in to comment.