系统ID#
对于使用以下代码的Linux发行版 systemd (Ubuntu、Debian、Arch Linux)您可以通过以下方式创建守护进程。
首先,在中创建Postgrest配置 /etc/postgrest/config
db-uri = "postgres://<your_user>:<your_password>@localhost:5432/<your_db>"
db-schemas = "<your_exposed_schema>"
db-anon-role = "<your_anon_role>"
jwt-secret = "<your_secret>"
创建专用的 postgrest
用户:
sudo useradd -M -U -d /nonexistent -s /usr/sbin/nologin postgrest
然后在中创建system d服务文件 /etc/systemd/system/postgrest.service
[Unit]
Description=REST API for any PostgreSQL database
After=postgresql.service
[Service]
User=postgrest
Group=postgrest
ExecStart=/bin/postgrest /etc/postgrest/config
ExecReload=/bin/kill -SIGUSR1 $MAINPID
[Install]
WantedBy=multi-user.target
之后,您可以在启动时启用该服务,并通过以下方式启动:
systemctl enable postgrest
systemctl start postgrest
## For reloading the service
## systemctl restart postgrest
文件描述符#
文件描述符是由HTTP连接(以及其他连接)使用的内核资源。每个进程的文件描述符都受到限制。内核的默认限制是1024,这在某些Linux发行版中有所增加。在流量较大的情况下,PostgREST可以达到此限制并开始显示 No file descriptors available
错误。要清除这些错误,可以增加进程的文件描述符限制。
[Service]
LimitNOFILE=10000