Reduce unnecessary apache restarts
Systemd limits the total number of restarts that a service can undergo
in a short period of time. On faster nodes all of our apache restarts
hit that limit and we eventually fail. Mitigate this by removing
unnecessary restarts.
Change-Id: I425bb9eec525d82372f05edc63e4fb931e5a4887
diff --git a/lib/apache b/lib/apache
index fc174f3..15b4297 100644
--- a/lib/apache
+++ b/lib/apache
@@ -53,13 +53,16 @@
# Enable apache mod and restart apache if it isn't already enabled.
function enable_apache_mod {
local mod=$1
+ local should_restart=$2
# Apache installation, because we mark it NOPRIME
if is_ubuntu; then
# Skip mod_version as it is not a valid mod to enable
# on debuntu, instead it is built in.
if [[ "$mod" != "version" ]] && ! a2query -m $mod ; then
sudo a2enmod $mod
- restart_apache_server
+ if [[ "$should_restart" != "norestart" ]] ; then
+ restart_apache_server
+ fi
fi
elif is_fedora; then
# pass
@@ -113,15 +116,18 @@
fi
if is_ubuntu; then
- # we've got to enable proxy and proxy_uwsgi for this to work
- sudo a2enmod proxy
- sudo a2enmod proxy_uwsgi
+ if ! a2query -m proxy || ! a2query -m proxy_uwsgi ; then
+ # we've got to enable proxy and proxy_uwsgi for this to work
+ sudo a2enmod proxy
+ sudo a2enmod proxy_uwsgi
+ restart_apache_server
+ fi
elif is_fedora; then
# redhat is missing a nice way to turn on/off modules
echo "LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so" \
| sudo tee /etc/httpd/conf.modules.d/02-proxy-uwsgi.conf
+ restart_apache_server
fi
- restart_apache_server
}
# install_apache_wsgi() - Install Apache server and wsgi module