mirror of
https://github.com/YunoHost-Apps/pagure_ynh.git
synced 2024-09-03 19:56:19 +02:00
Upgrade uwsgi helper
This commit is contained in:
parent
26fe5423f8
commit
636a871b02
7 changed files with 31 additions and 36 deletions
|
@ -6,8 +6,6 @@ location __PATH__ {
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
# Needed for long running operations in admin interface
|
# Needed for long running operations in admin interface
|
||||||
uwsgi_read_timeout 3600;
|
uwsgi_read_timeout 3600;
|
||||||
uwsgi_param SCRIPT_NAME __PATH__;
|
|
||||||
uwsgi_modifier1 30;
|
|
||||||
uwsgi_pass unix:///var/run/uwsgi/__NAME__.socket;
|
uwsgi_pass unix:///var/run/uwsgi/__NAME__.socket;
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
# Include SSOWAT user panel.
|
||||||
|
|
|
@ -6,6 +6,7 @@ After=syslog.target
|
||||||
ExecStart=/usr/bin/uwsgi \
|
ExecStart=/usr/bin/uwsgi \
|
||||||
--ini /etc/uwsgi/apps-available/%i.ini \
|
--ini /etc/uwsgi/apps-available/%i.ini \
|
||||||
--socket /var/run/uwsgi/%i.socket \
|
--socket /var/run/uwsgi/%i.socket \
|
||||||
|
--chmod-socket=775 \
|
||||||
--logto /var/log/uwsgi/app/%i
|
--logto /var/log/uwsgi/app/%i
|
||||||
User=%i
|
User=%i
|
||||||
Group=www-data
|
Group=www-data
|
||||||
|
@ -14,3 +15,6 @@ KillSignal=SIGQUIT
|
||||||
Type=notify
|
Type=notify
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
NotifyAccess=all
|
NotifyAccess=all
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -1,11 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Socket for uWSGI app %i
|
|
||||||
|
|
||||||
[Socket]
|
|
||||||
ListenStream=/var/run/uwsgi/%i.socket
|
|
||||||
SocketUser=%i
|
|
||||||
SocketGroup=www-data
|
|
||||||
SocketMode=0775
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=sockets.target
|
|
|
@ -4,9 +4,16 @@ master = true
|
||||||
protocol = uwsgi
|
protocol = uwsgi
|
||||||
socket = /var/run/uwsgi/__APP__.socket
|
socket = /var/run/uwsgi/__APP__.socket
|
||||||
virtualenv = __FINALPATH__/venv
|
virtualenv = __FINALPATH__/venv
|
||||||
wsgi-file = __FINALPATH__/pagure.wsgi
|
|
||||||
## master = [master process (true of false)]
|
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
|
||||||
master = true
|
mount = __PATH__=__FINALPATH__/pagure.wsgi
|
||||||
|
manage-script-name = true
|
||||||
|
|
||||||
|
# Increase number of workers for heavily loaded sites
|
||||||
|
# Needed for background processing
|
||||||
|
enable-threads = true
|
||||||
|
# Child processes do not need file descriptors
|
||||||
|
close-on-exec = true
|
||||||
## processes = [number of processes]
|
## processes = [number of processes]
|
||||||
processes = 5
|
processes = 5
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Pagure is a git-centered forge, python based using pygit2."
|
"en": "Pagure is a git-centered forge, python based using pygit2."
|
||||||
},
|
},
|
||||||
"version": "3.13.2-1",
|
"version": "3.13.2-2",
|
||||||
"url": "https://pagure.io/pagure",
|
"url": "https://pagure.io/pagure",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -3,13 +3,7 @@
|
||||||
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"
|
uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency"
|
||||||
|
|
||||||
if [ -f /etc/systemd/system/uwsgi-app@.service ];
|
cp ../conf/uwsgi-app@.service /etc/systemd/system/uwsgi-app@.service
|
||||||
then
|
|
||||||
echo "Uwsgi generic file is already installed"
|
|
||||||
else
|
|
||||||
cp ../conf/uwsgi-app@.socket /etc/systemd/system/uwsgi-app@.socket
|
|
||||||
cp ../conf/uwsgi-app@.service /etc/systemd/system/uwsgi-app@.service
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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/
|
||||||
|
@ -61,12 +55,12 @@ ynh_add_uwsgi_service () {
|
||||||
ynh_store_file_checksum "$finaluwsgiini"
|
ynh_store_file_checksum "$finaluwsgiini"
|
||||||
|
|
||||||
chown root: "$finaluwsgiini"
|
chown root: "$finaluwsgiini"
|
||||||
systemctl enable "uwsgi-app@$app.socket"
|
|
||||||
systemctl start "uwsgi-app@$app.socket"
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
systemctl enable "uwsgi-app@$app.service"
|
||||||
|
|
||||||
# Add as a service
|
# Add as a service
|
||||||
yunohost service add "uwsgi-app@$app.socket" --log "/var/log/uwsgi/app/$app"
|
yunohost service add "uwsgi-app@$app.service" --log "/var/log/uwsgi/app/$app"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove the dedicated uwsgi ini file
|
# Remove the dedicated uwsgi ini file
|
||||||
|
@ -75,17 +69,15 @@ ynh_add_uwsgi_service () {
|
||||||
ynh_remove_uwsgi_service () {
|
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.socket"
|
systemctl stop "uwsgi-app@$app.service"
|
||||||
systemctl disable "uwsgi-app@$app.socket"
|
systemctl disable "uwsgi-app@$app.service"
|
||||||
yunohost service remove "uwsgi-app@$app.socket"
|
yunohost service remove "uwsgi-app@$app.service"
|
||||||
|
|
||||||
ynh_secure_remove "$finaluwsgiini"
|
ynh_secure_remove "$finaluwsgiini"
|
||||||
ynh_secure_remove "/var/run/uwsgi/$app.socket"
|
|
||||||
ynh_secure_remove "/var/log/uwsgi/app/$app"
|
ynh_secure_remove "/var/log/uwsgi/app/$app"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
#
|
#
|
||||||
# POSTGRES HELPERS
|
# POSTGRES HELPERS
|
||||||
|
|
|
@ -84,11 +84,10 @@ ynh_install_app_dependencies git python-virtualenv libgit2-dev \
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid "$app")
|
db_name=$(ynh_sanitize_dbid "$app")
|
||||||
db_pwd=$(ynh_string_random)
|
|
||||||
# Initialize database and store postgres password for upgrade
|
|
||||||
ynh_psql_create_db "$db_name" "$app" "$db_pwd"
|
|
||||||
ynh_app_setting_set "$app" db_name "$db_name"
|
ynh_app_setting_set "$app" db_name "$db_name"
|
||||||
ynh_app_setting_set "$app" db_pwd "$db_pwd"
|
|
||||||
|
# Initialize database and store postgres password for upgrade
|
||||||
|
ynh_psql_setup_db "$db_name" "$app"
|
||||||
|
|
||||||
systemctl reload postgresql
|
systemctl reload postgresql
|
||||||
|
|
||||||
|
@ -195,6 +194,12 @@ then
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START PAGURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl start "uwsgi-app@$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue