Skip to main content

Fixing Whoogle after Debian upgrade + updating Whoogle

Whoogle is the other service that is now unable to start after upgrading from Debian 10 to Debian 11. Just like with Searx, I suspect the problem will have something to do with Python, since both apps are built using Flask, which is a micro web framework written in Python. However, I have been postponing upgrading to the newest version of Whoogle for a while now, so I will use this opportunity to first perform an upgrade.

Upgrading Whoogle

Check and stop the service
$ systemctl status whoogle

● whoogle.service - Whoogle
     Loaded: loaded (/etc/systemd/system/whoogle.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-09-15 14:57:08 CEST; 48ms ago
   Main PID: 157075 (python3)
        CPU: 16ms
     CGroup: /system.slice/whoogle.service
             └─157075 /var/www/whoogle/venv/bin/python3 -um app --host 127.0.0.1 --port 5000

Sep 15 14:57:08 hledej.nl01 whoogle[157075]:     __import__(pkg_name)
Sep 15 14:57:08 hledej.nl01 whoogle[157075]:   File "/var/www/whoogle/app/__init__.py", line 1, in <module>
Sep 15 14:57:08 hledej.nl01 whoogle[157075]:     from app.request import send_tor_signal
Sep 15 14:57:08 hledej.nl01 whoogle[157075]:   File "/var/www/whoogle/app/request.py", line 1, in <module>
Sep 15 14:57:08 hledej.nl01 whoogle[157075]:     from app.models.config import Config
Sep 15 14:57:08 hledej.nl01 whoogle[157075]:   File "/var/www/whoogle/app/models/config.py", line 1, in <module>
Sep 15 14:57:08 hledej.nl01 whoogle[157075]:     from flask import current_app
Sep 15 14:57:08 hledej.nl01 whoogle[157075]: ModuleNotFoundError: No module named 'flask'
Sep 15 14:57:08 hledej.nl01 systemd[1]: whoogle.service: Main process exited, code=exited, status=1/FAILURE
Sep 15 14:57:08 hledej.nl01 systemd[1]: whoogle.service: Failed with result 'exit-code'.

We can see that the service is trying to start but is unable to. Let's leave that for a while, stop the service and perform an upgrade.

$ sudo systemctl stop whoogle

Confirm that the service has stopped.

$ sudo systemctl status whoogle

● whoogle.service - Whoogle
     Loaded: loaded (/etc/systemd/system/whoogle.service; enabled; vendor preset: enabled)
     Active: inactive (dead) (Result: exit-code) since Wed 2021-09-15 14:57:26 CEST; 10min ago
    Process: 157082 ExecStart=/var/www/whoogle/venv/bin/python3 -um app --host 127.0.0.1 --port 5000 (code=exited, status=1/>
   Main PID: 157082 (code=exited, status=1/FAILURE)
        CPU: 105ms

Sep 15 14:57:24 hledej.nl01 systemd[1]: whoogle.service: Main process exited, code=exited, status=1/FAILURE
Sep 15 14:57:24 hledej.nl01 systemd[1]: whoogle.service: Failed with result 'exit-code'.
Sep 15 14:57:26 hledej.nl01 systemd[1]: Stopped Whoogle.
Temporarily add shell to Whoogle user

Whoogle is also running under a separate user who owns its directory and since we will be performing management tasks as this user, we need it to have shell access. Replace /usr/sbin/nologin with /bin/bash on the whoogle line in /etc/passwd.

$ sudo vi /etc/passwd

whoogle:x:1001:1001:,,,:/home/whoogle:/usr/sbin/nologin

to

whoogle:x:1001:1001:,,,:/home/whoogle:/bin/bash
Backup existing config file

All configuration of Whoogle is done using the whoogle.env file located in the root of the Whoogle folder, in my case /var/www/whoogle. Backup this file before upgrading. This will copy the file to the home directory of Whoogle user.

(whoogle)$ cp /var/www/whoogle/whoogle.env ~/
Clone the newest version

Move to the home directory of Whoogle user.

(whoogle)$ cd

Once in there, clone the Git repository.

(whoogle)$ git clone https://github.com/benbusby/whoogle-search.git
Merge the config file

Across versions, config files may change in structure or add/remove options. Always check manually.

Move to the cloned repository and merge your old whoogle.env with the downloaded one. In this case, the newer config was structured a bit differently, so I kept the new one and replaced some values in it.

(whoogle)$ cd whoogle-search && vi whoogle.env
Delete and replace with new version

You could just copy and rewrite everything in /var/www/whoogle with new files, but that poses the risk of leaving some old files behind or running into permission issues. That's why I decided to completely remove files from the old directory and then copy in the new version. This is essentially a reinstall of the service, but everything we need is backed up in the config file, so we are not loosing any data.

Heads up – This isn't exactly the fastest way to perform an upgrade and even if it can be done in 5 minutes, in availability dependent environments, consider options like rerouting traffic to another web server and switching back once everything is ready and tested.

There is a way to do it in one command, but I didn't want to spend more time on this.

Make sure you are deleting the right directory! This will delete everything without asking.

(whoogle)$ rm -rvf /var/www/whoogle/*
(whoogle)$ rm -rvf /var/www/whoogle/.*

Copy the download files to /var/www/whoogle, you have to be in the correct directory for it to work.

(whoogle)$ cp -av whoogle-searx/. /var/www/whoogle/