From 50ca67433f084c120fde60e10a5968e343826952 Mon Sep 17 00:00:00 2001 From: moctardiouf Date: Mon, 29 Apr 2024 19:05:08 +0200 Subject: [PATCH] PHRAS-4053 redis native session (#4505) * PHRASEANET_USER_SESSION_LIFETIME as php session.gc_maxlifetime * dissociate PHRASEANET_SESSION_TYPE and php SESSION_SAVE_HANDLER --- .env | 2 +- docker/phraseanet/php.ini.sample | 2 +- docker/phraseanet/setup/entrypoint.sh | 17 ++++++----------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.env b/.env index f07a86b58a..43bde72aa3 100644 --- a/.env +++ b/.env @@ -485,7 +485,7 @@ PHRASEANET_CACHE_HOST=redis # @run PHRASEANET_CACHE_PORT=6379 -# PHP session management +# PHP session management : this must be related to the SESSION_SAVE_HANDLER parameter. type can be redis, file or native # @run PHRASEANET_SESSION_TYPE=redis # @run diff --git a/docker/phraseanet/php.ini.sample b/docker/phraseanet/php.ini.sample index f122f8ce15..a4c714dc60 100644 --- a/docker/phraseanet/php.ini.sample +++ b/docker/phraseanet/php.ini.sample @@ -1412,7 +1412,7 @@ session.gc_divisor = 1000 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. ; http://php.net/session.gc-maxlifetime -session.gc_maxlifetime = 1440 +session.gc_maxlifetime = $PHRASEANET_USER_SESSION_LIFETIME ; NOTE: If you are using the subdirectory option for storing session files ; (see session.save_path above), then garbage collection does *not* diff --git a/docker/phraseanet/setup/entrypoint.sh b/docker/phraseanet/setup/entrypoint.sh index 7fb412c193..8abaad59c7 100755 --- a/docker/phraseanet/setup/entrypoint.sh +++ b/docker/phraseanet/setup/entrypoint.sh @@ -157,21 +157,16 @@ if [[ -f "$FILE" && $PHRASEANET_SETUP = 1 ]]; then fi echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet setting session type" - echo `date +"%Y-%m-%d %H:%M:%S"` " - SESSION_SAVE_HANDLER is $SESSION_SAVE_HANDLER" - - if [[ $SESSION_SAVE_HANDLER == file ]]; then - bin/setup system:config set main.session.type "$SESSION_SAVE_HANDLER" - echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is $SESSION_SAVE_HANDLER" - elif [[ $SESSION_SAVE_HANDLER == redis ]]; then - echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is Redis : setting Host to $PHRASEANET_SESSION_TYPE" - bin/setup system:config set main.session.type $PHRASEANET_SESSION_TYPE + echo `date +"%Y-%m-%d %H:%M:%S"` " - PHRASEANET_SESSION_TYPE is $PHRASEANET_SESSION_TYPE" + + bin/setup system:config set main.session.type "$PHRASEANET_SESSION_TYPE" + + if [[ $PHRASEANET_SESSION_TYPE == redis ]]; then + echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is Redis : setting redis connexion parameters" bin/setup system:config set main.session.options.host $PHRASEANET_SESSION_HOST bin/setup system:config set main.session.options.port $PHRASEANET_SESSION_PORT bin/setup system:config set main.session.options.namespace $PHRASEANET_HOSTNAME bin/setup system:config set main.session.ttl $PHRASEANET_USER_SESSION_LIFETIME - else - bin/setup system:config set main.session.type "native" - echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet PHP session manager is Native" fi ## Phraseanet application Database setting