1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[Unit]
Description=PostgreSQL API Service
After=network.target postgresql.service
Wants=postgresql.service
[Service]
Type=simple
User=pg-api
Group=pg-api
WorkingDirectory=/opt/prod/pg-api
# Configuration file in /etc for security
EnvironmentFile=/etc/pg-api/pg-api.env
ExecStart=/opt/prod/pg-api/target/release/pg-api
Restart=always
RestartSec=10
# Security
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
# Allow writing to logs directory only
ReadWritePaths=/opt/prod/pg-api/logs
# Resource Limits
LimitNOFILE=65536
MemoryMax=2G
CPUQuota=400%
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=pg-api
[Install]
WantedBy=multi-user.target