1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00

Standardize start systemd action and update uwsgi helper

This commit is contained in:
Josué Tille 2020-12-07 16:29:43 +01:00
parent 4082157e14
commit 6e8233b9b0
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
6 changed files with 17 additions and 14 deletions

View file

@ -4,7 +4,7 @@
app=$YNH_APP_INSTANCE_NAME
final_path=/opt/yunohost/$app
pgadmin_user="pgadmin"
pgadmin_user="$app"
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
dependances="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev"

View file

@ -42,10 +42,9 @@ ynh_add_nginx_config
ynh_add_uwsgi_service 'pgadmin_user python_version'
# Reload services
ynh_script_progression --message="Reloading services..."
sudo systemctl reload nginx.service
ynh_script_progression --message="Restarting $app services..." --weight=3
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action restart \
--line_match "WSGI app 0 \(mountpoint='$path_url'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/pgadmin.log"
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
sleep 10
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -9,22 +9,24 @@ ynh_check_global_uwsgi_config () {
uwsgi --version || ynh_die --message="You need to add uwsgi (and appropriate plugin) as a dependency"
cat > /etc/systemd/system/uwsgi-app@.service <<EOF
[Unit]
Description=%i uWSGI app
After=syslog.target
[Service]
RuntimeDirectory=%i
ExecStart=/usr/bin/uwsgi \
--ini /etc/uwsgi/apps-available/%i.ini \
--socket /var/run/%i/app.socket \
--socket /run/%i/app.socket \
--logto /var/log/uwsgi/%i/%i.log
User=%i
Group=www-data
Restart=on-failure
Restart=always
RestartSec=10
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
EOF
@ -49,6 +51,10 @@ EOF
#
# To be able to customise the settings of the systemd unit you can override the rules with the file "conf/uwsgi-app@override.service".
# This file will be automatically placed on the good place
#
# Note that the service need to be started manually at the end of the installation.
# Generally you can start the service with this command:
# ynh_systemd_action --service_name "uwsgi-app@$app.service" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
#
# usage: ynh_add_uwsgi_service
#
@ -100,9 +106,7 @@ ynh_add_uwsgi_service () {
cp ../conf/uwsgi-app@override.service /etc/systemd/system/uwsgi-app@$app.service.d/override.conf
systemctl daemon-reload
systemctl stop "uwsgi-app@$app.service" || true
systemctl enable "uwsgi-app@$app.service"
systemctl start "uwsgi-app@$app.service"
# Add as a service
yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log"

View file

@ -121,9 +121,9 @@ ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/pgadmin
# reload uwsgi
ynh_script_progression --message="Starting pgadmin services..." --weight=3
ynh_script_progression --message="Starting $app services..." --weight=3
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
--line_match "WSGI app 0 \(mountpoint='$path_url'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/pgadmin.log"
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
sleep 10
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -77,7 +77,7 @@ ynh_use_logrotate --logfile /var/log/pgadmin
# reload uwsgi and nginx
ynh_script_progression --message="Starting pgadmin services..." --weight=3
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
--line_match "WSGI app 0 \(mountpoint='$path_url'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/pgadmin.log"
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
systemctl reload nginx
sleep 10

View file

@ -71,9 +71,9 @@ ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
# reload uwsgi
ynh_script_progression --message="Restarting pgadmin services..." --weight=3
ynh_script_progression --message="Restarting $app services..." --weight=3
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
--line_match "WSGI app 0 \(mountpoint='$path_url'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/pgadmin.log"
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
sleep 10
ynh_script_progression --message="Upgrade of $app completed" --last