Systemd

In this installation method you use a special papermerge command startetc to generate a bunch of configuration files in <papermerge-proj>/run/etc folder. Then only with one single command:

systemctl --user start papermerge

you start a full fledged staging environment with nginx, gunicorn, one worker and recurring commands running as services on a single machine. I really love this method and I use in my local development environment. This method relies on systemd and its --user argument.

Package Dependencies

You will need to install os specific packages first.

Make sure that your machine has both nginx and systemd available:

nginx -V
systemd --version

Web App

Clone main papermerge project:

git clone --depth 1 --branch v1.3.0  https://github.com/ciur/papermerge papermerge-proj

Create python’s virtual environment .env:

cd papermerge-proj
python3 -m venv .venv

Activate python’s virtual environment:

source .venv/bin/activate

Install required python packages (now you are in papermerge-proj directory):

# while in <papermerge-proj> folder
pip install -r requirements.txt

Rename file config/settings/development.example.py to config/settings/development.py. This file is default for DJANGO_SETTINGS_MODULE and it is included in .gitignore.

In project root directory create papermerge.conf.py and add there MEDIA_DIR for example. In case you leave papermerge.conf.py empty - default values will be used.

Then, as in any django based project, run migrations and create super user:

cd <papermerge-proj>
./manage.py migrate
./manage.py collectstatic
./manage.py createsuperuser

Run startetc command:

./manage.py startetc

Just out of curiousity, have a look <papermerge-proj>/run at folder generated by startetc command. Folder <papermerge-proj> should have following structure:

run
├── etc
│   ├── gunicorn.conf.py
│   ├── nginx.conf
│   ├── papermerge.env
│   └── systemd
│       ├── papermerge.service
│       ├── papermerge.target
│       ├── mg_nginx.service
│       ├── worker.service
├── log
└── tmp

Systemd can be used to manage user services. For that –user flag is used. User services must be referenced in ~/.config/systemd/user folder.

Create ~/.config/systemd/user if you don’t have it. Then reference (create symbolic links) <papermerge-proj>/run/etc/systemd/ units in ~/.config/systemd/user folder:

cd ~/.config/systemd/user
ln -s <papermerge-proj>/run/etc/systemd/* .

Important

Path <papermerge-proj>/run/etc/systemd/* must be absolute.

Start papermerge:

systemctl --user start papermerge.target