diff --git a/Makefile b/Makefile index e92343c..70cfecd 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ PACKAGE_NAME := pgmon VERSION := 1.0 + BUILD_DIR := build + DEB_IMAGE := debian-package-builder RPM_IMAGE := rpm-package-builder SCRIPT := src/$(PACKAGE_NAME).py # Top-level targets -.PHONY: all clean deb rpm +.PHONY: all clean deb rpm test all: deb rpm @@ -28,6 +30,8 @@ rpm: clean: rm -rf $(BUILD_DIR) +test: + cd src ; python3 -m unittest # Container targets .PHONY: docker deb-package-image rpm-package-image @@ -56,22 +60,22 @@ package-rpm: cp RPM/$(PACKAGE_NAME).spec /output/SPECS/ rpmbuild --define '_topdir /output' \ --define 'version $(VERSION)' \ - -ba /output/SPECS/$(PACKAGE_NAME).spec - cp /output/rpm/RPMS/x86_64/*.rpm /output/ + -bb /output/SPECS/$(PACKAGE_NAME).spec + cp /output/RPMS/x86_64/*.rpm /output/ # Install into the specified destination directory (used inside the packaging systems) .PHONY: install install: # Set up directories - mkdir -p $(DESTDIR)/usr/bin + mkdir -p $(DESTDIR)/usr/local/bin mkdir -p $(DESTDIR)/usr/share/man/man1 mkdir -p $(DESTDIR)/etc/$(PACKAGE_NAME) mkdir -p $(DESTDIR)/lib/systemd/system # Install script - cp script.py $(DESTDIR)/usr/bin/$(PACKAGE_NAME) - chmod 755 $(DESTDIR)/usr/bin/$(PACKAGE_NAME) + cp $(SCRIPT) $(DESTDIR)/usr/local/bin/$(PACKAGE_NAME) + chmod 755 $(DESTDIR)/usr/local/bin/$(PACKAGE_NAME) # Install manpage cp manpages/* $(DESTDIR)/usr/share/man/man1/ diff --git a/RPM/pgmon.spec b/RPM/pgmon.spec index 53c5323..1428214 100644 --- a/RPM/pgmon.spec +++ b/RPM/pgmon.spec @@ -13,8 +13,10 @@ Requires: python3, python3-psycopg2, systemd A bridge to sit between monitoring tools and PostgreSQL %prep +# Do nothing since we don't need a tarball %build +# Do nothing since we have nothing to build %install make -C /src install DESTDIR=%{buildroot} diff --git a/manpages/pgmon.1 b/manpages/pgmon.1 new file mode 100644 index 0000000..e69de29 diff --git a/systemd/pgmon.service b/systemd/pgmon.service new file mode 100644 index 0000000..15b969f --- /dev/null +++ b/systemd/pgmon.service @@ -0,0 +1,14 @@ +# This is a meta unit modeled after the PostgreSQL unit file from the Debian +# packages. + +[Unit] +Description=PostgreSQL monitoring bridge + +[Service] +Type=oneshot +ExecStart=/bin/true +ExecReload=/bin/true +RemainAfterExit=on + +[Install] +WantedBy=multi-user.target diff --git a/systemd/pgmon@.service b/systemd/pgmon@.service index 420b124..c4172fe 100644 --- a/systemd/pgmon@.service +++ b/systemd/pgmon@.service @@ -1,11 +1,11 @@ [unit] Description=PostgreSQL Monitoring Bridge -#PartOf=pgmon.service -#Before=pgmon.service +PartOf=pgmon.service +Before=pgmon.service After=network.target [Service] -ExecStart=/usr/local/bin/pgmon.py /etc/pgmon/%i.cfg +ExecStart=/usr/local/bin/pgmon /etc/pgmon/%i.yml ExecReload=kill -HUP $MAINPID Restart=on-failure Type=exec