[Feature Request] systemd scripts
Please find below the systemd scripts I use on Debian.
PostgREST executable is in /usr/bin/postgrest
Multiples configuration files are /etc/postgrest/xxx.conf
Note: must take care to use a different port in each config file.
I test the following commands:
systemctl enable postgrest
systemctl disable postgrest
systemctl stop postgrest
systemctl start postgrest
systemctl enable postgrest@xxx
systemctl disable postgrest@xxx
systemctl stop postgrest@xxx
systemctl start postgrest@xxx
/etc/systemd/system/postgrest.service
[Unit]
Description=REST API for Postgres database
After=postgresql.service
[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on
[Install]
WantedBy=multi-user.target
/etc/systemd/system/[email protected]
[Unit]
Description=REST API for Postgres database %i
AssertPathExists=/etc/postgrest/%i.conf
PartOf=postgrest.service
ReloadPropagatedFrom=postgrest.service
Before=postgrest.service
[Service]
ExecStart=/usr/bin/postgrest /etc/postgrest/%i.conf
ExecReload=/bin/kill -SIGUSR1 $MAINPID
Restart=on-failure
[Install]
WantedBy=postgrest.service
Hey @geepie, thanks for sharing!
We do have a systemd section on: https://postgrest.org/en/v7.0.0/admin.html#daemonizing.
Perhaps we can include your recommendations there.
(I'll transfer the issue to our docs repo).
@geepie Could you elaborate how postgrest.service and [email protected] work?
systemctl start postgrest@xxx AssertPathExists=/etc/postgrest/%i.conf
Does %i gets replaced by xxx?
Let's expand on this in the docs. It would be difficult to provide any scripts that apply across distros. @geepie, any additonal background that you can provide on your scripts?