Browse code

Use packaged uwsgi on Fedora and Ubuntu

Building uwsgi from source was a workaround that was introduced a long
time ago, it doesn't seem like it is needed anymore and will actually
fail for Ubuntu 20.04.

Also it doesn't match what will happen for most real-world
installations, so let's try to get back to using distro packages. We'll
still use the source install for RHEL/Centos, it remains to be tested
whether we can get back to using distro versions there, too.

Change-Id: I82f539bfa533349293dd5a8ce309c9cc0ffb0393

Ian Wienand authored on 2018/05/03 09:51:30
Showing 1 changed files
... ...
@@ -82,26 +82,52 @@ function install_apache_uwsgi {
82 82
         apxs="apxs"
83 83
     fi
84 84
 
85
-    # Ubuntu xenial is back level on uwsgi so the proxy doesn't
86
-    # actually work. Hence we have to build from source for now.
85
+    # This varies based on packaged/installed.  If we've
86
+    # pip_installed, then the pip setup will only build a "python"
87
+    # module that will be either python2 or python3 depending on what
88
+    # it was built with.
87 89
     #
88
-    # Centos 7 actually has the module in epel, but there was a big
89
-    # push to disable epel by default. As such, compile from source
90
-    # there as well.
91
-
92
-    local dir
93
-    dir=$(mktemp -d)
94
-    pushd $dir
95
-    pip_install uwsgi
96
-    pip download uwsgi -c $REQUIREMENTS_DIR/upper-constraints.txt
97
-    local uwsgi
98
-    uwsgi=$(ls uwsgi*)
99
-    tar xvf $uwsgi
100
-    cd uwsgi*/apache2
101
-    sudo $apxs -i -c mod_proxy_uwsgi.c
102
-    popd
103
-    # delete the temp directory
104
-    sudo rm -rf $dir
90
+    # For package installs, the distro ships both plugins and you need
91
+    # to select the right one ... it will not be autodetected.
92
+    if python3_enabled; then
93
+        UWSGI_PYTHON_PLUGIN=python3
94
+    else
95
+        UWSGI_PYTHON_PLUGIN=python
96
+    fi
97
+
98
+    if is_ubuntu; then
99
+        install_package uwsgi \
100
+                        uwsgi-plugin-python \
101
+                        uwsgi-plugin-python3 \
102
+                        libapache2-mod-proxy-uwsgi
103
+    elif [[ $os_VENDOR == "Fedora" ]]; then
104
+        # Note httpd comes with mod_proxy_uwsgi and it is loaded by
105
+        # default; the mod_proxy_uwsgi package actually conflicts now.
106
+        # See:
107
+        #  https://bugzilla.redhat.com/show_bug.cgi?id=1574335
108
+        #
109
+        # Thus there is nothing else to do after this install
110
+        install_package uwsgi \
111
+                        uwsgi-plugin-python3
112
+    else
113
+        # Centos actually has the module in epel, but there was a big
114
+        # push to disable epel by default. As such, compile from source
115
+        # there.
116
+        local dir
117
+        dir=$(mktemp -d)
118
+        pushd $dir
119
+        pip_install uwsgi
120
+        pip download uwsgi -c $REQUIREMENTS_DIR/upper-constraints.txt
121
+        local uwsgi
122
+        uwsgi=$(ls uwsgi*)
123
+        tar xvf $uwsgi
124
+        cd uwsgi*/apache2
125
+        sudo $apxs -i -c mod_proxy_uwsgi.c
126
+        popd
127
+        # delete the temp directory
128
+        sudo rm -rf $dir
129
+        UWSGI_PYTHON_PLUGIN=python
130
+    fi
105 131
 
106 132
     if is_ubuntu || is_suse ; then
107 133
         # we've got to enable proxy and proxy_uwsgi for this to work
... ...
@@ -265,7 +291,7 @@ function write_uwsgi_config {
265 265
     # configured after graceful shutdown
266 266
     iniset "$file" uwsgi worker-reload-mercy $WORKER_TIMEOUT
267 267
     iniset "$file" uwsgi enable-threads true
268
-    iniset "$file" uwsgi plugins python
268
+    iniset "$file" uwsgi plugins http,${UWSGI_PYTHON_PLUGIN}
269 269
     # uwsgi recommends this to prevent thundering herd on accept.
270 270
     iniset "$file" uwsgi thunder-lock true
271 271
     # Set hook to trigger graceful shutdown on SIGTERM
... ...
@@ -318,7 +344,7 @@ function write_local_uwsgi_http_config {
318 318
     iniset "$file" uwsgi die-on-term true
319 319
     iniset "$file" uwsgi exit-on-reload false
320 320
     iniset "$file" uwsgi enable-threads true
321
-    iniset "$file" uwsgi plugins python
321
+    iniset "$file" uwsgi plugins http,${UWSGI_PYTHON_PLUGIN}
322 322
     # uwsgi recommends this to prevent thundering herd on accept.
323 323
     iniset "$file" uwsgi thunder-lock true
324 324
     # Set hook to trigger graceful shutdown on SIGTERM