From 4e2b0f03d0939c863acb013ae51abe3f34c69c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 16 Jan 2019 17:30:48 +0100 Subject: [PATCH 1/4] fix dependance for service start --- conf/uwsgi-app@.service | 20 -------------------- conf/uwsgi-app@override.service | 2 ++ scripts/_common.sh | 32 +++++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 21 deletions(-) delete mode 100644 conf/uwsgi-app@.service create mode 100644 conf/uwsgi-app@override.service diff --git a/conf/uwsgi-app@.service b/conf/uwsgi-app@.service deleted file mode 100644 index f61228d..0000000 --- a/conf/uwsgi-app@.service +++ /dev/null @@ -1,20 +0,0 @@ -[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 \ - --logto /var/log/uwsgi/%i/%i.log -User=%i -Group=www-data -Restart=on-failure -KillSignal=SIGQUIT -Type=notify -StandardError=syslog -NotifyAccess=all - -[Install] -WantedBy=multi-user.target diff --git a/conf/uwsgi-app@override.service b/conf/uwsgi-app@override.service new file mode 100644 index 0000000..eac7a8f --- /dev/null +++ b/conf/uwsgi-app@override.service @@ -0,0 +1,2 @@ +[Unit] +After=mysql.service diff --git a/scripts/_common.sh b/scripts/_common.sh index 6d7e3bb..d8fdb5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,28 @@ ynh_check_global_uwsgi_config () { uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" - cp ../conf/uwsgi-app@.service /etc/systemd/system/uwsgi-app@.service + cat >> /etc/systemd/system/uwsgi-app@.service < uwsgi-app@app` @@ -70,6 +94,11 @@ ynh_add_uwsgi_service () { chown $app:root /var/log/uwsgi/$app chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app + # Setup specific Systemd rules if necessary + test -e ../conf/uwsgi-app@override.service && \ + mkdir /etc/systemd/system/uwsgi-app@$app.service.d && \ + 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" systemctl enable "uwsgi-app@$app.service" @@ -91,5 +120,6 @@ ynh_remove_uwsgi_service () { ynh_secure_remove "$finaluwsgiini" ynh_secure_remove "/var/log/uwsgi/$app" + ynh_secure_remove "/etc/systemd/system/uwsgi-app@$app.service.d" fi } From f60088d74772ab9db99d6fda4085549abc5a5a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 8 Feb 2019 18:06:28 +0100 Subject: [PATCH 2/4] Don't fail if systemd unit fail to stop --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d8fdb5a..c76eb33 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -100,7 +100,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" + systemctl stop "uwsgi-app@$app.service" || true systemctl enable "uwsgi-app@$app.service" systemctl start "uwsgi-app@$app.service" From 699d7553c5a3635624a5092ce41e11fcab288668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Mon, 11 Feb 2019 15:54:38 +0100 Subject: [PATCH 3/4] Fix helper --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c76eb33..03dfd56 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ ynh_check_global_uwsgi_config () { uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" - cat >> /etc/systemd/system/uwsgi-app@.service < /etc/systemd/system/uwsgi-app@.service < Date: Tue, 12 Feb 2019 20:15:04 +0100 Subject: [PATCH 4/4] Fix virtualenv setup --- scripts/install | 6 +++--- scripts/upgrade | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 1764eb3..a872873 100644 --- a/scripts/install +++ b/scripts/install @@ -114,7 +114,7 @@ ynh_system_user_create "$app" "$final_path" # pip installation #================================================= -virtualenv "$final_path/local" +virtualenv --python=$(which python2 python | head -n 1) "$final_path/local" # Init virtualenv ( set +o nounset @@ -122,10 +122,10 @@ virtualenv "$final_path/local" set -o nounset cd "$final_path" pip install --upgrade pip - pip install pyramid_chameleon + pip install --upgrade pyramid_chameleon CFLAGS="-Wno-error -Wno-error=format-security" \ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \ - pip install --requirement "$final_path/requirements.txt" + pip install --upgrade --requirement "$final_path/requirements.txt" python "$final_path/setup.py" develop diff --git a/scripts/upgrade b/scripts/upgrade index 84eb1d6..437b9f0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -133,7 +133,7 @@ ynh_system_user_create "$app" # pip installation #================================================= -virtualenv "$final_path/local" +virtualenv --python=$(which python2 python | head -n 1) "$final_path/local" # Init virtualenv ( set +o nounset @@ -141,10 +141,10 @@ virtualenv "$final_path/local" set -o nounset cd "$final_path" pip install --upgrade pip - pip install pyramid_chameleon + pip install --upgrade pyramid_chameleon CFLAGS="-Wno-error -Wno-error=format-security" \ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \ - pip install --requirement "$final_path/requirements.txt" + pip install --upgrade --requirement "$final_path/requirements.txt" python "$final_path/setup.py" develop