mirror of
https://github.com/YunoHost-Apps/tracim_ynh.git
synced 2024-10-01 13:34:52 +02:00
switch sessions to redis
This commit is contained in:
parent
2189716c80
commit
29a59fd898
8 changed files with 75 additions and 22 deletions
|
@ -278,12 +278,12 @@ preview_cache_dir = %(basic_setup.preview_cache_dir)s
|
|||
|
||||
### pyramid_beaker parameters ###
|
||||
|
||||
session.type = file
|
||||
session.type = ext:redis
|
||||
# needed for "file" storage config :
|
||||
; session.data_dir = %(here)s/sessions_data
|
||||
session.data_dir = %(basic_setup.sessions_data_root_dir)s/sessions_data
|
||||
# needed for many session storage type, but not for file (leave as empty for file)
|
||||
session.url =
|
||||
session.url = redis://localhost:6379/__REDIS_DB__
|
||||
|
||||
## "Redis" storage config sample:
|
||||
# session.type = ext:redis
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="postgresql ghostscript git imagemagick iproute2 libfile-mimeinfo-perl libimage-exiftool-perl webp libmagic1 locales poppler-utils python3 python3-pip uwsgi uwsgi-plugin-python3 supervisor"
|
||||
pkg_dependencies="postgresql ghostscript git imagemagick iproute2 libfile-mimeinfo-perl libimage-exiftool-perl webp libmagic1 locales poppler-utils python3 python3-pip uwsgi uwsgi-plugin-python3 supervisor redis-server"
|
||||
|
||||
preview_pkg_dependencies="ffmpeg xvfb inkscape libreoffice"
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ chown $app:$app "$final_path/frontend/configEnv.json"
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI"
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||
ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_supervisor
|
||||
source ynh_redis
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -146,6 +147,9 @@ chown -R $app:www-data "$datadir"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
redis_db=$(ynh_redis_get_free_db)
|
||||
ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db
|
||||
|
||||
ynh_add_config --template="../conf/development.ini.sample" --destination="$final_path/backend/development.ini"
|
||||
chmod 400 "$final_path/backend/development.ini"
|
||||
chown $app:$app "$final_path/backend/development.ini"
|
||||
|
@ -226,7 +230,7 @@ ln -sf /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-ca
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/$app.log"
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/$app-web.log"
|
||||
yunohost service add supervisor --log="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
@ -235,7 +239,7 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log"
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI"
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||
ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_supervisor
|
||||
source ynh_redis
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -23,6 +24,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -31,20 +33,15 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
#=================================================
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
if ynh_exec_warn_less yunohost service status uwsgi >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
ynh_script_progression --message="Removing uwsgi service integration..."
|
||||
yunohost service remove uwsgi
|
||||
fi
|
||||
if ynh_exec_warn_less yunohost service status $app-webdav >/dev/null
|
||||
if ynh_exec_warn_less yunohost service status supervisor >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-webdav service integration..."
|
||||
yunohost service remove $app-webdav
|
||||
fi
|
||||
if ynh_exec_warn_less yunohost service status $app-caldav >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-caldav service integration..."
|
||||
yunohost service remove $app-caldav
|
||||
ynh_script_progression --message="Removing supervisor service integration..."
|
||||
yunohost service remove supervisor
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -61,7 +58,7 @@ ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-webdav.ini"
|
|||
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-webdav.ini"
|
||||
ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app-caldav.ini"
|
||||
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app-caldav.ini"
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI"
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart"
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
|
@ -104,11 +101,22 @@ ynh_remove_nginx_config
|
|||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_redis_remove_db "$redis_db"
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/uwsgi/app/$app-web.log"
|
||||
ynh_secure_remove --file="/var/log/uwsgi/app/$app-webdav.log"
|
||||
ynh_secure_remove --file="/var/log/uwsgi/app/$app-caldav.log"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -138,7 +138,7 @@ supervisorctl update
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/$app.log"
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/$app-web.log"
|
||||
yunohost service add supervisor --log="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
@ -147,7 +147,7 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log"
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI"
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||
ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_supervisor
|
||||
source ynh_redis
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -29,6 +30,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
api_key=$(ynh_app_setting_get --app=$app --key=api_key)
|
||||
session_secret=$(ynh_app_setting_get --app=$app --key=session_secret)
|
||||
website_title=$(ynh_app_setting_get --app=$app --key=website_title)
|
||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -200,7 +202,7 @@ ln -sf /etc/uwsgi/apps-available/$app-caldav.ini /etc/uwsgi/apps-enabled/$app-ca
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/$app.log"
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/$app-web.log"
|
||||
yunohost service add supervisor --log="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
@ -209,7 +211,7 @@ yunohost service add supervisor --log="/var/log/supervisor/supervisord.log"
|
|||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app.log" --line_match="spawned uWSGI"
|
||||
ynh_systemd_action --service_name="uwsgi" --action="restart" --log_path="/var/log/uwsgi/app/$app-web.log" --line_match="spawned uWSGI"
|
||||
ynh_supervisor_action --service_name="$app" --action="restart" --log_path="/var/log/supervisor/supervisord.log"
|
||||
|
||||
#=================================================
|
||||
|
|
39
scripts/ynh_redis
Normal file
39
scripts/ynh_redis
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get the first available redis database
|
||||
#
|
||||
# usage: ynh_redis_get_free_db
|
||||
# | returns: the database number to use
|
||||
ynh_redis_get_free_db() {
|
||||
local result max db
|
||||
result=$(redis-cli INFO keyspace)
|
||||
|
||||
# get the num
|
||||
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
||||
|
||||
db=0
|
||||
# default Debian setting is 15 databases
|
||||
for i in $(seq 0 "$max")
|
||||
do
|
||||
if ! echo "$result" | grep -q "db$i"
|
||||
then
|
||||
db=$i
|
||||
break 1
|
||||
fi
|
||||
db=-1
|
||||
done
|
||||
|
||||
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
|
||||
|
||||
echo "$db"
|
||||
}
|
||||
|
||||
# Create a master password and set up global settings
|
||||
# Please always call this script in install and restore scripts
|
||||
#
|
||||
# usage: ynh_redis_remove_db database
|
||||
# | arg: database - the database to erase
|
||||
ynh_redis_remove_db() {
|
||||
local db=$1
|
||||
redis-cli -n "$db" flushall
|
||||
}
|
Loading…
Reference in a new issue