mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-11-25 17:20:41 +08:00
bug fix
This commit is contained in:
parent
1d33fc405a
commit
f72ea7a7d1
1 changed files with 5 additions and 8 deletions
|
@ -30,8 +30,6 @@ class CheckFailed(Exception):
|
||||||
pass
|
pass
|
||||||
class NeedrestartFailed(Exception):
|
class NeedrestartFailed(Exception):
|
||||||
pass
|
pass
|
||||||
class SystemdNotRunning(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def sync() -> None:
|
def sync() -> None:
|
||||||
logger.info('sync start')
|
logger.info('sync start')
|
||||||
|
@ -217,7 +215,7 @@ def main() -> None:
|
||||||
exit(1)
|
exit(1)
|
||||||
if SYSTEMD:
|
if SYSTEMD:
|
||||||
if _s := is_system_failed():
|
if _s := is_system_failed():
|
||||||
logger.error(f'systemd is not in {_s} state, refused')
|
logger.error(f'systemd is in {_s} state, refused')
|
||||||
exit(11)
|
exit(11)
|
||||||
if prev_err := has_previous_error():
|
if prev_err := has_previous_error():
|
||||||
logger.error(f'Cannot continue, a previous error {prev_err} is still present. Please resolve this issue and run fail-reset.')
|
logger.error(f'Cannot continue, a previous error {prev_err} is still present. Please resolve this issue and run fail-reset.')
|
||||||
|
@ -237,8 +235,8 @@ def main() -> None:
|
||||||
else:
|
else:
|
||||||
if report._warn or report._crit:
|
if report._warn or report._crit:
|
||||||
exc = CheckFailed('manual inspection required')
|
exc = CheckFailed('manual inspection required')
|
||||||
|
write_db(report, exc)
|
||||||
if exc:
|
if exc:
|
||||||
write_db(report, exc)
|
|
||||||
exit(2)
|
exit(2)
|
||||||
if NEEDRESTART:
|
if NEEDRESTART:
|
||||||
try:
|
try:
|
||||||
|
@ -253,11 +251,10 @@ def main() -> None:
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.error(f'needrestart failed with {e.returncode=} {e.output=}')
|
logger.error(f'needrestart failed with {e.returncode=} {e.output=}')
|
||||||
exc = NeedrestartFailed(f'{e.returncode=}')
|
exc = NeedrestartFailed(f'{e.returncode=}')
|
||||||
|
write_db(None, exc)
|
||||||
|
exit(2)
|
||||||
else:
|
else:
|
||||||
logger.debug(f'needrestart {p.stdout=}')
|
logger.debug(f'needrestart {p.stdout=}')
|
||||||
write_db(report, exc)
|
|
||||||
if exc:
|
|
||||||
exit(2)
|
|
||||||
|
|
||||||
elif args.action == 'status':
|
elif args.action == 'status':
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -272,7 +269,7 @@ def main() -> None:
|
||||||
elif args.action == 'fail-reset':
|
elif args.action == 'fail-reset':
|
||||||
if SYSTEMD:
|
if SYSTEMD:
|
||||||
if _s := is_system_failed():
|
if _s := is_system_failed():
|
||||||
logger.error(f'systemd is not in {_s} state, refused')
|
logger.error(f'systemd is in {_s} state, refused')
|
||||||
exit(11)
|
exit(11)
|
||||||
if getuid() != 0:
|
if getuid() != 0:
|
||||||
logger.error('you need to be root')
|
logger.error('you need to be root')
|
||||||
|
|
Loading…
Reference in a new issue