Skip to content

Commit b058f26

Browse files
committed
Renamed entrypoint script and configured better log output configuration (Fixes #463)
1 parent 16562b3 commit b058f26

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

docs/content/docs/2.getting-started/3.default-configurations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ We also provide a few default scripts to help you get started.
102102
| **Script Name** | **Description** | **Image variations** |
103103
|------------|-----------------|----------------------|
104104
| `0-container-info.sh` | Shows basic execution information, such as Docker User, UID, GID, etc. | all |
105-
| `1-debug-mode.sh` | Sets PHP to debug mode if `LOG_OUTPUT_LEVEL = "debug"` | all |
105+
| `1-log-output-level.sh` | Sets PHP log output level to match `LOG_OUTPUT_LEVEL` | all |
106106
| `10-init-unit.sh` | Processes Unit templates, configures SSL (if enabled), and prepares NGINX Unit for launch | unit |
107107
| `10-init-webserver-config.sh` | Processes web server configuration templates, configures SSL (if enabled), and prepares web server for launch | *-nginx <br/> *-apache |
108108
| `50-laravel-automations.sh` | If `AUTORUN_ENABLED` is set to true, and a Laravel installation is detected, the following commands will automatically execute on container start: <br/> - `php artisan config:cache` <br/> - `php artisan route:cache` <br/> - `php artisan view:cache` <br/> - `php artisan event:cache` <br/> - `php artisan migrate --force` | all |

src/common/etc/entrypoint.d/1-debug-mode.sh src/common/etc/entrypoint.d/1-log-output-level.sh

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
script_name="debug-mode"
2+
script_name="log-output-level"
33

44
if [ "$DISABLE_DEFAULT_CONFIG" = true ]; then
55
if [ "$LOG_OUTPUT_LEVEL" = "debug" ]; then
@@ -42,12 +42,19 @@ set_fpm_log_level (){
4242
fi
4343

4444
fpm_log_level=$1
45-
sed -i "/\[global\]/a log_level = $fpm_log_level" /usr/local/etc/php-fpm.conf
45+
46+
# Create a temporary file then move it, instead of requiring permissions to write to /usr/local/etc/
47+
tmp_file=$(mktemp /tmp/php-fpm.conf.XXXXXX)
48+
sed "/\[global\]/a log_level = $fpm_log_level" /usr/local/etc/php-fpm.conf > "$tmp_file"
49+
cat "$tmp_file" > /usr/local/etc/php-fpm.conf
50+
rm "$tmp_file"
4651
echo "ℹ️ NOTICE ($script_name): FPM - log_level has been set to \"$fpm_log_level\""
4752

48-
echo "access.log = /proc/self/fd/2" >> /usr/local/etc/php-fpm.d/zzz-docker-php-serversideup-fpm-debug.conf
49-
echo "access.format = \"fpm: %R - %u %t \"%m %r%Q%q\" %s duration=%{milliseconds}dms memory=%Mk cpu=%C%% pid=%p script=%f\"" >> /usr/local/etc/php-fpm.d/zzz-docker-php-serversideup-fpm-debug.conf
50-
echo "ℹ️ NOTICE ($script_name): FPM - access.log has been set to \"STDERR\""
53+
if [ "$fpm_log_level" = "debug" ]; then
54+
echo "access.log = /proc/self/fd/2" >> /usr/local/etc/php-fpm.d/zzz-docker-php-serversideup-fpm-debug.conf
55+
echo "access.format = \"fpm: %R - %u %t \"%m %r%Q%q\" %s duration=%{milliseconds}dms memory=%Mk cpu=%C%% pid=%p script=%f\"" >> /usr/local/etc/php-fpm.d/zzz-docker-php-serversideup-fpm-debug.conf
56+
echo "ℹ️ NOTICE ($script_name): FPM - access.log has been set to \"STDERR\""
57+
fi
5158
}
5259

5360
#######################################
@@ -83,7 +90,7 @@ case "$LOG_OUTPUT_LEVEL" in
8390
set_fpm_log_level alert
8491
;;
8592
*)
86-
echo "👉 $script_name: LOG_OUTPUT_LEVEL is not set to a valid value. Please set it to one of the following: debug, info, notice, warn, error, crit, alert, emerg."
93+
echo "❌ ERROR ($script_name): LOG_OUTPUT_LEVEL is not set to a valid value. Please set it to one of the following: debug, info, notice, warn, error, crit, alert, emerg."
8794
return 1
8895
;;
8996
esac

0 commit comments

Comments
 (0)