Add systemd service (#540)

This commit is contained in:
Lev Kokotov
2023-08-08 11:51:38 -07:00
committed by GitHub
parent 2ca21b2bec
commit 7c3c90c38e
5 changed files with 35 additions and 1 deletions

16
pgcat.service Normal file
View File

@@ -0,0 +1,16 @@
[Unit]
Description=PgCat pooler
After=network.target
StartLimitIntervalSec=0
[Service]
User=pgcat
Type=simple
Restart=always
RestartSec=1
Environment=RUST_LOG=info
LimitNOFILE=65536
ExecStart=/usr/bin/pgcat /etc/pgcat.toml
[Install]
WantedBy=multi-user.target

4
postinst Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
systemctl daemon-reload
systemctl enable pgcat

3
postrm Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
systemctl daemon-reload

4
prerm Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
systemctl stop pgcat
systemctl disable pgcat

View File

@@ -17,14 +17,21 @@ cargo build --release
rm -rf "$deb_dir"
mkdir -p "$deb_dir/DEBIAN"
mkdir -p "$deb_dir/usr/bin"
mkdir -p "$deb_dir/etc"
mkdir -p "$deb_dir/etc/systemd/system"
cp target/release/pgcat "$deb_dir/usr/bin/pgcat"
chmod +x "$deb_dir/usr/bin/pgcat"
cp pgcat.toml "$deb_dir/etc/pgcat.toml"
cp pgcat.service "$deb_dir/etc/systemd/system/pgcat.service"
(cat control | envsubst) > "$deb_dir/DEBIAN/control"
cp postinst "$deb_dir/DEBIAN/postinst"
cp postrm "$deb_dir/DEBIAN/postrm"
cp prerm "$deb_dir/DEBIAN/prerm"
chmod +x ${deb_dir}/DEBIAN/post*
chmod +x ${deb_dir}/DEBIAN/pre*
dpkg-deb \
--root-owner-group \