service: Switch to systemd user service
Run as the current user instead of a dedicated system user, using systemd user service in ~/.config/systemd/user/. This avoids needing root for setup and keeps uv and the project in the user's home directory. Rename service file to matrix-paperless-ingest.service.
This commit is contained in:
parent
d5a3528cde
commit
b2646222f8
2 changed files with 15 additions and 19 deletions
25
README.md
25
README.md
|
|
@ -102,23 +102,20 @@ uv run --no-sync python ingest.py
|
||||||
Watch the logs. It will process all historical messages, then listen for new ones.
|
Watch the logs. It will process all historical messages, then listen for new ones.
|
||||||
Press Ctrl-C to stop.
|
Press Ctrl-C to stop.
|
||||||
|
|
||||||
## Install as a systemd service
|
## Install as a systemd user service
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create a dedicated user
|
# Enable lingering so the service starts at boot without requiring login
|
||||||
sudo useradd -r -s /bin/false matrix-paperless-ingest
|
loginctl enable-linger
|
||||||
|
|
||||||
# Copy the project
|
# Install the service
|
||||||
sudo cp -r . /opt/matrix-paperless-ingest
|
mkdir -p ~/.config/systemd/user
|
||||||
sudo chown -R matrix-paperless-ingest:matrix-paperless-ingest /opt/matrix-paperless-ingest
|
cp matrix-paperless-ingest.service ~/.config/systemd/user/
|
||||||
|
systemctl --user daemon-reload
|
||||||
# Install and start the service
|
systemctl --user enable --now matrix-paperless-ingest
|
||||||
sudo cp paperless-ingest.service /etc/systemd/system/
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable --now paperless-ingest
|
|
||||||
|
|
||||||
# Check logs
|
# Check logs
|
||||||
sudo journalctl -u paperless-ingest -f
|
journalctl --user -u matrix-paperless-ingest -f
|
||||||
```
|
```
|
||||||
|
|
||||||
## Viewing retry queue
|
## Viewing retry queue
|
||||||
|
|
@ -129,7 +126,7 @@ sqlite3 state.db "SELECT filename, status, retry_count, datetime(next_retry, 'un
|
||||||
|
|
||||||
## Moving to a new server
|
## Moving to a new server
|
||||||
|
|
||||||
1. Copy the project directory (including `.env` and `state.db`)
|
1. Copy the project directory to `~/matrix-paperless-ingest` (including `.env` and `state.db`)
|
||||||
2. Install `uv`, `libolm3`, and `python3-olm` on the new server
|
2. Install `uv`, `libolm3`, and `python3-olm` on the new server
|
||||||
3. Run `uv venv --system-site-packages && uv sync --no-install-package python-olm`
|
3. Run `uv venv --system-site-packages && uv sync --no-install-package python-olm`
|
||||||
4. Install the systemd service as above
|
4. Install the systemd user service as above
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,13 @@ Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=matrix-paperless-ingest
|
WorkingDirectory=%h/matrix-paperless-ingest
|
||||||
WorkingDirectory=/opt/matrix-paperless-ingest
|
EnvironmentFile=%h/matrix-paperless-ingest/.env
|
||||||
EnvironmentFile=/opt/matrix-paperless-ingest/.env
|
ExecStart=%h/.local/bin/uv run --no-sync python ingest.py
|
||||||
ExecStart=uv run --no-sync python ingest.py
|
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=default.target
|
||||||
Loading…
Add table
Add a link
Reference in a new issue