[Unit]
Description=Paperless-ngx webserver
After=network.target tailscaled.service redis-server.service postgresql.service
Requires=redis-server.service postgresql.service tailscaled.service

[Service]
Type=simple
User={{ paperless_sys_user }}
Group={{ paperless_sys_group }}
WorkingDirectory={{ paperless_install_path }}/src
EnvironmentFile={{ paperless_install_path }}/paperless.conf

Environment=GRANIAN_HOST={{ paperless_bind_addr }}
Environment=GRANIAN_PORT={{ paperless_port }}
Environment=GRANIAN_WORKERS=1

ExecStart={{ paperless_install_path }}/venv/bin/granian --interface asginl --ws paperless.asgi:application

Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateDevices=true
PrivateTmp=true
ProtectSystem=strict
ProtectControlGroups=true
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ReadWritePaths={{ paperless_install_path }} {{ paperless_data_dir }} {{ paperless_media_root }} {{ paperless_consumption_dir }}
UMask=0027

[Install]
WantedBy=multi-user.target
