Skip to content

improve logs #155

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion glpi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,21 @@ COPY --from=builder --chown=www-data:www-data /usr/src/glpi /var/www/glpi
RUN mkdir /var/glpi && chown www-data:www-data /var/glpi
VOLUME /var/glpi

# make a directory for GLPI logs.
RUN mkdir -p /var/log/glpi && chown www-data:www-data /var/log/glpi

# Define GLPI environment variables
ENV \
GLPI_INSTALL_MODE=DOCKER \
GLPI_CONFIG_DIR=/var/glpi/config \
GLPI_VAR_DIR=/var/glpi/files
GLPI_VAR_DIR=/var/glpi/files \
GLPI_LOG_DIR=/var/log/glpi

# disable apache access logs
RUN rm /var/log/apache2/access.log
RUN rm /var/log/apache2/other_vhosts_access.log
RUN ln -sfT /dev/null /var/log/apache2/access.log
RUN ln -sfT /dev/null /var/log/apache2/other_vhosts_access.log

# Make startup script executable and executes it as default command.
RUN chmod u+x /opt/startup.sh
Expand Down
1 change: 0 additions & 1 deletion glpi/files/etc/apache2/sites-available/000-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
DocumentRoot /var/www/glpi/public

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/glpi/public>
Require all granted
Expand Down
22 changes: 21 additions & 1 deletion glpi/files/opt/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,29 @@ done
# Set ACL for www-data user on marketplace directory
setfacl -m user:www-data:rwx,group:www-data:rwx "/var/www/glpi/marketplace"

# forward logs files to /proc/1/fd/1
# see https://stackoverflow.com/a/63713129
logs=(
"event.log"
"cron.log"
"mail.log"
"php-errors.log"
"sql-errors.log"
"mail-errors.log"
"access-error.log"
)
for log in "${logs[@]}"
do
if [ ! -f /var/log/glpi/$log ];
then
touch /var/log/glpi/$log
setfacl -m user:www-data:rwx,group:www-data:rwx /var/log/glpi/$log
fi
done
tail -f /var/log/glpi/*.log > /proc/1/fd/1 &

# Run cron service.
cron

# Run command previously defined in base php-apache Dockerfile.
apache2-foreground