From 077e3cff458e4c36b364c065397d524025ee3de1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 8 Oct 2019 20:52:03 +0200 Subject: Increase import size (#2563) * Increase import size This is merely a temporary workaround to allow at least some medium size imports https://framateam.org/freshrss/pl/7wbt4tcyetrfmris9xdcbq7uuw The import module should be rewritten to process files one by one and as data streams instead of loading multiple copies of the whole dataset in memory as is the case now :-( https://github.com/FreshRSS/FreshRSS/issues/1890 Note that the new SQLite export/import is distinct from this case. * Use parameter --- Docker/entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Docker/entrypoint.sh') diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.sh index bb0e1bde0..dcbd7e231 100755 --- a/Docker/entrypoint.sh +++ b/Docker/entrypoint.sh @@ -6,6 +6,8 @@ chown -R :www-data . chmod -R g+r . && chmod -R g+w ./data/ find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \; +find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?post_max_size#s#^.*#post_max_size = 32M#" {} \; +find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?upload_max_filesize#s#^.*#upload_max_filesize = 32M#" {} \; if [ -n "$CRON_MIN" ]; then ( -- cgit v1.2.3 From 3c49986ec895595edc632da0f14419199ce47667 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 26 Oct 2019 11:19:42 +0200 Subject: New environment variable COPY_LOG_TO_SYSLOG (#2591) * New environment variable COPY_LOG_TO_SYSLOG False by default. Makes it easy to monitor all logs from Syslog or STDERR (e.g. docker logs). * Suggestion of native constants --- Docker/Dockerfile | 3 ++- Docker/Dockerfile-Alpine | 1 + Docker/Dockerfile-QEMU-ARM | 1 + Docker/entrypoint.sh | 1 + constants.php | 1 + lib/Minz/Log.php | 44 ++++++++++++++++++-------------------------- 6 files changed, 24 insertions(+), 27 deletions(-) (limited to 'Docker/entrypoint.sh') diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 19923bcf1..6dbebccb0 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -43,10 +43,11 @@ RUN a2dismod -f alias autoindex negotiation status && \ RUN sed -r -i "/^\s*(CustomLog|ErrorLog|Listen) /s/^/#/" /etc/apache2/apache2.conf && \ sed -r -i "/^\s*Listen /s/^/#/" /etc/apache2/ports.conf && \ touch /var/www/FreshRSS/Docker/env.txt && \ - echo "17,47 * * * * . /var/www/FreshRSS/Docker/env.txt; \ + echo "7,37 * * * * . /var/www/FreshRSS/Docker/env.txt; \ su www-data -s /bin/sh -c 'php /var/www/FreshRSS/app/actualize_script.php' \ 2>> /proc/1/fd/2 > /tmp/FreshRSS.log" | crontab - +ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' ENV FRESHRSS_ENV '' diff --git a/Docker/Dockerfile-Alpine b/Docker/Dockerfile-Alpine index 3b1f1a394..4afad0949 100644 --- a/Docker/Dockerfile-Alpine +++ b/Docker/Dockerfile-Alpine @@ -43,6 +43,7 @@ RUN rm -f /etc/apache2/conf.d/languages.conf /etc/apache2/conf.d/info.conf \ su apache -s /bin/sh -c 'php /var/www/FreshRSS/app/actualize_script.php' \ 2>> /proc/1/fd/2 > /tmp/FreshRSS.log" | crontab - +ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' ENV FRESHRSS_ENV '' diff --git a/Docker/Dockerfile-QEMU-ARM b/Docker/Dockerfile-QEMU-ARM index f7389fcbc..30b1e205b 100644 --- a/Docker/Dockerfile-QEMU-ARM +++ b/Docker/Dockerfile-QEMU-ARM @@ -59,6 +59,7 @@ RUN update-ca-certificates -f # Useful with the `--squash` build option RUN rm /usr/bin/qemu-* /var/www/FreshRSS/Docker/qemu-* +ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' ENV FRESHRSS_ENV '' diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.sh index dcbd7e231..02338c35e 100755 --- a/Docker/entrypoint.sh +++ b/Docker/entrypoint.sh @@ -12,6 +12,7 @@ find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?upload_max_filesize#s#^.*#u if [ -n "$CRON_MIN" ]; then ( echo "export TZ=$TZ" + echo "export COPY_LOG_TO_SYSLOG=$COPY_LOG_TO_SYSLOG" echo "export COPY_SYSLOG_TO_STDERR=$COPY_SYSLOG_TO_STDERR" ) >/var/www/FreshRSS/Docker/env.txt crontab -l | sed -r "\\#FreshRSS#s#^[^ ]+ #$CRON_MIN #" | crontab - diff --git a/constants.php b/constants.php index 76a320616..2ccf91358 100644 --- a/constants.php +++ b/constants.php @@ -32,6 +32,7 @@ safe_define('FRESHRSS_USERAGENT', 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS // PHP text output compression http://php.net/ob_gzhandler (better to do it at Web server level) safe_define('PHP_COMPRESSION', false); +safe_define('COPY_LOG_TO_STDERR', filter_var(getenv('COPY_LOG_TO_STDERR'), FILTER_VALIDATE_BOOLEAN)); // For cases when syslog is not available safe_define('COPY_SYSLOG_TO_STDERR', filter_var(getenv('COPY_SYSLOG_TO_STDERR'), FILTER_VALIDATE_BOOLEAN)); diff --git a/lib/Minz/Log.php b/lib/Minz/Log.php index a8dbf8350..3e6a25f27 100644 --- a/lib/Minz/Log.php +++ b/lib/Minz/Log.php @@ -8,26 +8,14 @@ * La classe Log permet de logger des erreurs */ class Minz_Log { - /** - * Les différents niveau de log - * ERROR erreurs bloquantes de l'application - * WARNING erreurs pouvant géner le bon fonctionnement, mais non bloquantes - * NOTICE erreurs mineures ou messages d'informations - * DEBUG Informations affichées pour le déboggage - */ - const ERROR = 2; - const WARNING = 4; - const NOTICE = 8; - const DEBUG = 16; - /** * Enregistre un message dans un fichier de log spécifique * Message non loggué si * - environment = SILENT - * - level = WARNING et environment = PRODUCTION - * - level = NOTICE et environment = PRODUCTION + * - level = LOG_WARNING et environment = PRODUCTION + * - level = LOG_NOTICE et environment = PRODUCTION * @param $information message d'erreur / information à enregistrer - * @param $level niveau d'erreur + * @param $level niveau d'erreur https://php.net/function.syslog * @param $file_name fichier de log * @throws Minz_PermissionDeniedException */ @@ -41,7 +29,7 @@ class Minz_Log { if (! ($env === 'silent' || ($env === 'production' - && ($level >= Minz_Log::NOTICE)))) { + && ($level >= LOG_NOTICE)))) { if ($file_name === null) { $username = Minz_Session::param('currentUser', ''); if ($username == '') { @@ -51,16 +39,16 @@ class Minz_Log { } switch ($level) { - case Minz_Log::ERROR : + case LOG_ERR : $level_label = 'error'; break; - case Minz_Log::WARNING : + case LOG_WARNING : $level_label = 'warning'; break; - case Minz_Log::NOTICE : + case LOG_NOTICE : $level_label = 'notice'; break; - case Minz_Log::DEBUG : + case LOG_DEBUG : $level_label = 'debug'; break; default : @@ -71,6 +59,10 @@ class Minz_Log { . ' [' . $level_label . ']' . ' --- ' . $information . "\n"; + if (defined('COPY_LOG_TO_SYSLOG') && COPY_LOG_TO_SYSLOG) { + syslog($level, '[' . $username . '] ' . $log); + } + self::ensureMaxLogSize($file_name); if (file_put_contents($file_name, $log, FILE_APPEND | LOCK_EX) === false) { @@ -120,8 +112,8 @@ class Minz_Log { $msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true)); $msg_post = str_replace("\n", '', '$_POST content : ' . print_r($_POST, true)); - self::record($msg_get, Minz_Log::DEBUG, $file_name); - self::record($msg_post, Minz_Log::DEBUG, $file_name); + self::record($msg_get, LOG_DEBUG, $file_name); + self::record($msg_post, LOG_DEBUG, $file_name); } /** @@ -129,15 +121,15 @@ class Minz_Log { * Parameters are the same of those of the record() method. */ public static function debug($msg, $file_name = null) { - self::record($msg, Minz_Log::DEBUG, $file_name); + self::record($msg, LOG_DEBUG, $file_name); } public static function notice($msg, $file_name = null) { - self::record($msg, Minz_Log::NOTICE, $file_name); + self::record($msg, LOG_NOTICE, $file_name); } public static function warning($msg, $file_name = null) { - self::record($msg, Minz_Log::WARNING, $file_name); + self::record($msg, LOG_WARNING, $file_name); } public static function error($msg, $file_name = null) { - self::record($msg, Minz_Log::ERROR, $file_name); + self::record($msg, LOG_ERR, $file_name); } } -- cgit v1.2.3