mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
fully use socket activation
This commit is contained in:
parent
ee63b07215
commit
fce38ffb8d
9 changed files with 31 additions and 50 deletions
|
@ -8,7 +8,7 @@ ExecStart=/usr/bin/uwsgi \
|
||||||
--socket /var/run/uwsgi/%i.socket \
|
--socket /var/run/uwsgi/%i.socket \
|
||||||
--logto /var/log/uwsgi/app/%i
|
--logto /var/log/uwsgi/app/%i
|
||||||
User=%i
|
User=%i
|
||||||
Group=uwsgi
|
Group=www-data
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
KillSignal=SIGQUIT
|
KillSignal=SIGQUIT
|
||||||
Type=notify
|
Type=notify
|
||||||
|
|
|
@ -4,8 +4,8 @@ Description=Socket for uWSGI app %i
|
||||||
[Socket]
|
[Socket]
|
||||||
ListenStream=/var/run/uwsgi/%i.socket
|
ListenStream=/var/run/uwsgi/%i.socket
|
||||||
SocketUser=%i
|
SocketUser=%i
|
||||||
SocketGroup=uwsgi
|
SocketGroup=www-data
|
||||||
SocketMode=0660
|
SocketMode=0775
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=sockets.target
|
WantedBy=sockets.target
|
||||||
|
|
|
@ -7,7 +7,6 @@ virtualenv = __FINALPATH__/venv
|
||||||
wsgi-file = __FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py
|
wsgi-file = __FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py
|
||||||
# Needed for OAuth/OpenID
|
# Needed for OAuth/OpenID
|
||||||
buffer-size = 8192
|
buffer-size = 8192
|
||||||
chmod-socket = 666
|
|
||||||
# Increase number of workers for heavily loaded sites
|
# Increase number of workers for heavily loaded sites
|
||||||
#workers = 6
|
#workers = 6
|
||||||
# Needed for background processing
|
# Needed for background processing
|
||||||
|
|
|
@ -3,26 +3,25 @@
|
||||||
current_version="2.17.1"
|
current_version="2.17.1"
|
||||||
|
|
||||||
ynh_check_global_uwsgi_config () {
|
ynh_check_global_uwsgi_config () {
|
||||||
|
uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency"
|
||||||
|
|
||||||
if [ -f /etc/systemd/system/uwsgi-app@.service ];
|
if [ -f /etc/systemd/system/uwsgi-app@.service ];
|
||||||
then
|
then
|
||||||
echo "Uwsgi generic file is already installed"
|
echo "Uwsgi generic file is already installed"
|
||||||
else
|
else
|
||||||
cp ../conf/uwsgi-app@.socket /etc/systemd/system/uwsgi-app@.socket
|
cp ../conf/uwsgi-app@.socket /etc/systemd/system/uwsgi-app@.socket
|
||||||
cp ../conf/uwsgi-app@.service /etc/systemd/system/uwsgi-app@.service
|
cp ../conf/uwsgi-app@.service /etc/systemd/system/uwsgi-app@.service
|
||||||
|
fi
|
||||||
# create uwsgi group
|
|
||||||
groupadd uwsgi
|
|
||||||
|
|
||||||
# make sure the folder for sockets exists and set authorizations
|
# make sure the folder for sockets exists and set authorizations
|
||||||
mkdir -p /var/run/uwsgi/
|
mkdir -p /var/run/uwsgi/
|
||||||
chown root:uwsgi /var/run/uwsgi/
|
chown root:www-data /var/run/uwsgi/
|
||||||
chmod -R 775 /var/run/uwsgi/
|
chmod -R 775 /var/run/uwsgi/
|
||||||
|
|
||||||
# make sure the folder for logs exists and set authorizations
|
# make sure the folder for logs exists and set authorizations
|
||||||
mkdir -p /var/log/uwsgi/app/
|
mkdir -p /var/log/uwsgi/app/
|
||||||
chown root:uwsgi /var/log/uwsgi/app/
|
chown root:www-data /var/log/uwsgi/app/
|
||||||
chmod -R 775 /var/log/uwsgi/app/
|
chmod -R 775 /var/log/uwsgi/app/
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a dedicated uwsgi ini file to use with generic uwsgi service
|
# Create a dedicated uwsgi ini file to use with generic uwsgi service
|
||||||
|
@ -37,14 +36,15 @@ ynh_check_global_uwsgi_config () {
|
||||||
# __FINALPATH__ by $final_path
|
# __FINALPATH__ by $final_path
|
||||||
#
|
#
|
||||||
# usage: ynh_add_systemd_config
|
# usage: ynh_add_systemd_config
|
||||||
ynh_add_uwsgi_config () {
|
ynh_add_uwsgi_service () {
|
||||||
ynh_check_global_uwsgi_config
|
ynh_check_global_uwsgi_config
|
||||||
|
|
||||||
usermod --append --groups uwsgi "$app" || ynh_die "It wasn't possible to add user $app to group uwsgi"
|
# www-data group is needed since it is this nginx who will start the service
|
||||||
|
usermod --append --groups www-data "$app" || ynh_die "It wasn't possible to add user $app to group www-data"
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
ynh_backup_if_checksum_is_different "$finaluwsgiini"
|
ynh_backup_if_checksum_is_different "$finaluwsgiini"
|
||||||
sudo cp ../conf/uwsgi.ini "$finaluwsgiini"
|
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||||
|
|
||||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||||
# Substitute in a nginx config file only if the variable is not empty
|
# Substitute in a nginx config file only if the variable is not empty
|
||||||
|
@ -57,22 +57,23 @@ ynh_add_uwsgi_config () {
|
||||||
ynh_store_file_checksum "$finaluwsgiini"
|
ynh_store_file_checksum "$finaluwsgiini"
|
||||||
|
|
||||||
chown root: "$finaluwsgiini"
|
chown root: "$finaluwsgiini"
|
||||||
systemctl enable "uwsgi-app@$app.service"
|
systemctl enable "uwsgi-app@$app.socket"
|
||||||
|
systemctl start "uwsgi-app@$app.socket"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
# Add as a service
|
# Add as a service
|
||||||
yunohost service add "uwsgi-app@$app.service" --log "/var/run/uwsgi/$app.socket"
|
yunohost service add "uwsgi-app@$app.socket" --log "/var/log/uwsgi/app/$app"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove the dedicated uwsgi ini file
|
# Remove the dedicated uwsgi ini file
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_systemd_config
|
# usage: ynh_remove_systemd_config
|
||||||
ynh_remove_uwsgi_config () {
|
ynh_remove_uwsgi_service () {
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
if [ -e "$finaluwsgiini" ]; then
|
if [ -e "$finaluwsgiini" ]; then
|
||||||
systemctl stop "uwsgi-app@$app.service"
|
systemctl stop "uwsgi-app@$app.socket"
|
||||||
systemctl disable "uwsgi-app@$app.service"
|
systemctl disable "uwsgi-app@$app.socket"
|
||||||
yunohost service remove "uwsgi-app@$app.service"
|
yunohost service remove "uwsgi-app@$app.socket"
|
||||||
|
|
||||||
ynh_secure_remove "$finaluwsgiini"
|
ynh_secure_remove "$finaluwsgiini"
|
||||||
fi
|
fi
|
||||||
|
@ -107,7 +108,7 @@ ynh_check_if_checksum_is_different() {
|
||||||
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
|
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
|
||||||
local check=0
|
local check=0
|
||||||
|
|
||||||
if ! echo "$checksum_value $file" | sudo md5sum -c --status
|
if ! echo "$checksum_value $file" | md5sum -c --status
|
||||||
then # If the checksum is now different
|
then # If the checksum is now different
|
||||||
check=1
|
check=1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -55,9 +55,3 @@ ynh_backup "db.sql"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/cron.d/$app"
|
ynh_backup "/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE UWSGI SERVICE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ EOF
|
||||||
# SPECIFIC SETUP uwsgi
|
# SPECIFIC SETUP uwsgi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_uwsgi_config
|
ynh_add_uwsgi_service
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
|
|
|
@ -58,7 +58,7 @@ ynh_secure_remove "/etc/cron.d/$app"
|
||||||
# REMOVE uwsgi and systemd files
|
# REMOVE uwsgi and systemd files
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_remove_uwsgi_config
|
ynh_remove_uwsgi_service
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -90,17 +90,7 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
||||||
# RESTORE THE SERVICE
|
# RESTORE THE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/uwsgi/apps-available/$app.ini"
|
ynh_add_uwsgi_service
|
||||||
|
|
||||||
ynh_check_global_uwsgi_config
|
|
||||||
|
|
||||||
systemctl enable "uwsgi-app@$app.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
yunohost service add "uwsgi-app@$app.service"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE CRON FILE
|
# RESTORE THE CRON FILE
|
||||||
|
|
|
@ -117,10 +117,7 @@ chsh --shell /bin/bash "$app"
|
||||||
# SPECIFIC SETUP uwsgi
|
# SPECIFIC SETUP uwsgi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_uwsgi_config
|
ynh_add_uwsgi_service
|
||||||
|
|
||||||
# Add weblate as a service
|
|
||||||
yunohost service add "uwsgi-app@$app.service"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
|
|
Loading…
Reference in a new issue