Skip to content

Add systemd service #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pgcat.service
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

systemctl daemon-reload
systemctl enable pgcat
3 changes: 3 additions & 0 deletions postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

systemctl daemon-reload
4 changes: 4 additions & 0 deletions prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

systemctl stop pgcat
systemctl disable pgcat
9 changes: 8 additions & 1 deletion utilities/deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down