From 80b6a49fd8f5afee490d59ff2f62861f4af02f03 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Tue, 23 Jul 2019 01:12:28 +0900 Subject: [PATCH] fix Makefile and .service --- Makefile | 67 ++++++++++++++++++++++++++------------------------ nohang | 4 +-- nohang.service | 11 +++------ oom-sort.1 | 2 ++ 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index aa629df..e02816b 100644 --- a/Makefile +++ b/Makefile @@ -1,51 +1,54 @@ -PREFIX = / +DESTDIR ?= +BINDIR ?= /usr/local/bin +SYSTEMDUNITDIR ?= /etc/systemd/system +CONFDIR ?= /etc +MANDIR ?= /usr/share/man/man1 +LOGDIR ?= /var/log all: @ echo "Use: make install, make systemd, make uninstall" install: - install -d $(DESTDIR)/$(PREFIX)/usr/sbin - install -m0755 ./nohang $(DESTDIR)/$(PREFIX)/usr/sbin/nohang - install -m0755 ./nohang_notify_helper $(DESTDIR)/$(PREFIX)/usr/sbin/nohang_notify_helper + install -d $(DESTDIR)$(BINDIR) + install -m0755 ./nohang $(DESTDIR)$(BINDIR)/nohang + install -m0755 ./nohang_notify_helper $(DESTDIR)$(BINDIR)/nohang_notify_helper + install -m0755 ./oom-sort $(DESTDIR)$(BINDIR)/oom-sort + install -m0755 ./psi-top $(DESTDIR)$(BINDIR)/psi-top + install -m0755 ./psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor - install -d $(DESTDIR)/$(PREFIX)/usr/bin - install -m0755 ./oom-sort $(DESTDIR)/$(PREFIX)/usr/bin/oom-sort - install -m0755 ./psi-top $(DESTDIR)/$(PREFIX)/usr/bin/psi-top - install -m0755 ./psi-monitor $(DESTDIR)/$(PREFIX)/usr/bin/psi-monitor - - install -d $(DESTDIR)/$(PREFIX)/etc/nohang + install -d $(DESTDIR)$(CONFDIR)/nohang -git describe --tags --long --dirty > ./version - -install -m0644 ./version $(DESTDIR)/$(PREFIX)/etc/nohang/version + -install -m0644 ./version $(DESTDIR)$(CONFDIR)/nohang/version -rm -fvr ./version - install -m0644 ./nohang.conf $(DESTDIR)/$(PREFIX)/etc/nohang/nohang.conf - install -m0644 ./nohang.conf $(DESTDIR)/$(PREFIX)/etc/nohang/nohang.conf.default + install -m0644 ./nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf + install -m0644 ./nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default - install -d $(DESTDIR)/$(PREFIX)/etc/logrotate.d - install -m0644 ./nohang.logrotate $(DESTDIR)/$(PREFIX)/etc/logrotate.d/nohang + install -d $(DESTDIR)$(CONFDIR)/logrotate.d + install -m0644 ./nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang - install -d $(DESTDIR)/$(PREFIX)/usr/share/man/man1 - gzip -c nohang.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/nohang.1.gz - gzip -c oom-sort.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/oom-sort.1.gz + install -d $(DESTDIR)$(MANDIR) + gzip -c nohang.1 > $(DESTDIR)$(MANDIR)/nohang.1.gz + gzip -c oom-sort.1 > $(DESTDIR)$(MANDIR)/oom-sort.1.gz - -install -d $(DESTDIR)/$(PREFIX)/lib/systemd/system - -install -m0644 ./nohang.service $(DESTDIR)/$(PREFIX)/lib/systemd/system/nohang.service - -chcon -t systemd_unit_file_t $(DESTDIR)/$(PREFIX)/lib/systemd/system/nohang.service + -install -d $(DESTDIR)$(SYSTEMDUNITDIR) + -install -m0644 ./nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service + -chcon -t systemd_unit_file_t $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service uninstall: # 'make uninstall' must not fail with error if systemctl is unavailable or returns error -systemctl disable nohang.service || true - rm -fv $(PREFIX)/usr/sbin/nohang - rm -fv $(PREFIX)/usr/sbin/nohang_notify_helper - rm -fv $(PREFIX)/usr/bin/oom-sort - rm -fv $(PREFIX)/usr/bin/psi-top - rm -fv $(PREFIX)/usr/bin/psi-monitor - rm -fv $(PREFIX)/usr/share/man/man1/nohang.1.gz - rm -fv $(PREFIX)/usr/share/man/man1/oom-sort.1.gz - rm -fv $(PREFIX)/lib/systemd/system/nohang.service - rm -fvr $(PREFIX)/etc/nohang/ - rm -fvr $(PREFIX)/etc/logrotate.d/nohang - rm -fvr $(PREFIX)/var/log/nohang/ + rm -fv $(DESTDIR)$(BINDIR)/nohang + rm -fv $(DESTDIR)$(BINDIR)/nohang_notify_helper + rm -fv $(DESTDIR)$(BINDIR)/oom-sort + rm -fv $(DESTDIR)$(BINDIR)/psi-top + rm -fv $(DESTDIR)$(BINDIR)/psi-monitor + rm -fv $(DESTDIR)$(MANDIR)/nohang.1.gz + rm -fv $(DESTDIR)$(MANDIR)/oom-sort.1.gz + rm -fv $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service + rm -fvr $(DESTDIR)$(CONFDIR)/nohang/ + rm -fvr $(DESTDIR)$(CONFDIR)/logrotate.d/nohang + rm -fvr $(DESTDIR)$(LOGDIR)/nohang/ systemd: -systemctl daemon-reload diff --git a/nohang b/nohang index 89f0a2e..a30866b 100755 --- a/nohang +++ b/nohang @@ -2300,7 +2300,7 @@ else: if os.path.exists('./nohang_notify_helper'): notify_helper_path = './nohang_notify_helper' else: - notify_helper_path = '/usr/sbin/nohang_notify_helper' + notify_helper_path = 'nohang_notify_helper' @@ -2396,7 +2396,7 @@ for s in mem_list: if mem_list_names[2] != 'MemAvailable': errprint('WARNING: Your Linux kernel is too old, Linux 3.14+ requied') - # exit(1) + exit(1) swap_total_index = mem_list_names.index('SwapTotal') swap_free_index = swap_total_index + 1 diff --git a/nohang.service b/nohang.service index e5c405f..3b3a3bd 100644 --- a/nohang.service +++ b/nohang.service @@ -1,20 +1,15 @@ [Unit] Description=Highly configurable OOM prevention daemon -After=sysinit.target Documentation=man:nohang(1) https://github.com/hakavlad/nohang [Service] -ExecStart=/usr/sbin/nohang --config /etc/nohang/nohang.conf +ExecStart=/usr/local/bin/nohang --config /etc/nohang/nohang.conf Slice=nohang.slice Restart=always KillMode=mixed -MemoryMax=50M +MemoryMax=100M TasksMax=50 -Nice=-20 -IOSchedulingClass=1 -IOSchedulingPriority=0 -CPUSchedulingPolicy=fifo -CPUSchedulingPriority=99 +Nice=-15 CPUSchedulingResetOnFork=true [Install] diff --git a/oom-sort.1 b/oom-sort.1 index b1bdbd8..1340da6 100644 --- a/oom-sort.1 +++ b/oom-sort.1 @@ -1,3 +1,5 @@ .TH oom-sort 1 + .SH NAME + oom-sort \- sort processes by oom_score