autocat3 is a python-based application used for supporting Project Gutenberg.
CherryPy is used as the web framework which is easy to develop.
It mainly implements the search functionality and rate limiter. Also return results pages based on templates.
The production version of autocat3 is on app1.
This application in this repository is on appdev1.
Previously, the old version of autocat3 relies on dependencies installed directly on the system. To make it more flexible and easy to deploy, we tend to use virtual env rather than the previous method. To use virtual env, we use pipenv instead of using pip and virtual env separately.
The virtual env directory is on the default directory while we run pipenv --three. So it's not in this directory. (We strictly use python3 for this project because CherryPy will discard the python2 in the future.)
To start the service/application, we use systemd to do that. the autocat3.service file is written under /etc/systemd/systemdirectory.
- PostgreSQL with the
gutenbergdatabase already populated - Root or sudo access
Install pyenv (see build prerequisites if needed) so that pipenv can install the required Python version. Then install pipenv:
pip install pipenvsudo useradd -r -m -d /var/lib/autocat -s /bin/bash autocat
sudo mkdir -p /var/lib/autocat/log
sudo mkdir -p /var/run/autocatsu - autocat # May need to add sudo depending on your system
git clone https://github.com/gutenbergtools/autocat3.git
# Or if from a branch/tag
git clone -b <tag-name> https://github.com/gutenbergtools/autocat3.git # If you want to clone only that branch/tag, add --single-branchpipenv reads the Pipfile and auto-detects Python 3.9 from pyenv. Setting PIPENV_VENV_IN_PROJECT puts the virtualenv in .venv/ inside the project directory so the systemd service can find it.
# Run as autocat user
cd /var/lib/autocat/autocat3
PIPENV_VENV_IN_PROJECT=1 pipenv installVerify:
# Run as autocat user
/var/lib/autocat/autocat3/.venv/bin/python --versionEdit /etc/autocat3.conf (or ~/.autocat3 under the autocat user) to override defaults from CherryPy.conf. At minimum, set your database credentials and hosts:
[global]
pghost: 'localhost'
pgport: 5432
pgdatabase: 'gutenberg'
pguser: 'postgres'The user must have sufficient permissions to access all public tables and refresh the materialized view.
To change when the materialized view refreshes (default 5 PM server time):
mv_refresh_hour: 17Other information on configuring Autocat3 can be found in configuring.txt
The service runs the app using the venv's Python directly:
sudo cp /var/lib/autocat/autocat3/autocat3.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable autocat3.servicesudo systemctl start autocat3.serviceCheck status:
sudo systemctl status autocat3.serviceLogs are written to /var/lib/autocat/log/error.log and /var/lib/autocat/log/access.log.
Some common service commands are:
sudo systemctl start autocat3.service # Start
sudo systemctl stop autocat3.service # Stop
sudo systemctl restart autocat3.service # Restart
sudo systemctl status autocat3.service # Check status
sudo systemctl daemon-reload # Reload after editing the unit fileCopyright 2009-2010 by Marcello Perathoner Copyright 2019-present by Project Gutenberg