Skip to content

Commit

Permalink
PHRAS-4053 redis native session (#4505)
Browse files Browse the repository at this point in the history
* PHRASEANET_USER_SESSION_LIFETIME as php session.gc_maxlifetime

* dissociate PHRASEANET_SESSION_TYPE and php SESSION_SAVE_HANDLER
  • Loading branch information
moctardiouf authored Apr 29, 2024
1 parent 9ffb992 commit 50ca674
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/phraseanet/php.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
17 changes: 6 additions & 11 deletions docker/phraseanet/setup/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50ca674

Please sign in to comment.