diff --git a/Makefile b/Makefile index f77b5c4..42fd530 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ install: install -m0644 ./nohang.conf $(DESTDIR)/$(PREFIX)/etc/nohang/$(VERSION) install -m0644 ./nohang.conf $(DESTDIR)/$(PREFIX)/etc/nohang/nohang.conf.default + install -m0644 ./nohang.logrotate $(DESTDIR)/$(PREFIX)/etc/logrotate.d/nohang + install -d $(DESTDIR)/$(PREFIX)/usr/share/man/man1 gzip -k -c nohang.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/nohang.1.gz gzip -k -c oom-sort.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/oom-sort.1.gz @@ -37,6 +39,7 @@ uninstall: rm -fv $(PREFIX)/usr/share/man/man1/oom-trigger.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/ systemd: diff --git a/nohang b/nohang index bb85eda..0e1b51a 100755 --- a/nohang +++ b/nohang @@ -1740,13 +1740,6 @@ else: exit(1) -if 'log_dir' in config_dict: - log_dir = config_dict['log_dir'] -else: - errprint('log_dir is not in config\nExit') - exit(1) - - print_total_stat = conf_parse_bool('print_total_stat') print_proc_table = conf_parse_bool('print_proc_table') @@ -1758,6 +1751,8 @@ if separate_log: from logging import basicConfig from logging import info + log_dir = '/var/log/nohang' + try: os.mkdir(log_dir) except PermissionError: diff --git a/nohang.conf b/nohang.conf index 9a89942..0b6be90 100644 --- a/nohang.conf +++ b/nohang.conf @@ -384,9 +384,6 @@ max_ancestry_depth = 1 separate_log = False -log_dir = /var/log/nohang - - ##################################################################### 9. Misc diff --git a/nohang.logrotate b/nohang.logrotate new file mode 100644 index 0000000..d05be46 --- /dev/null +++ b/nohang.logrotate @@ -0,0 +1,9 @@ +/var/log/nohang/*.log { + missingok + copytruncate + notifempty + size 1M + rotate 5 + compress + delaycompress +}