mirror of
https://github.com/frappe/bench.git
synced 2025-01-08 16:14:12 +00:00
Merge pull request #1343 from frappe/dummy-release-trigger
refactor: Use Suppress instead of try-pass
This commit is contained in:
commit
66d41e5c3d
@ -1,4 +1,5 @@
|
|||||||
# imports - standard imports
|
# imports - standard imports
|
||||||
|
import contextlib
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
@ -181,40 +182,25 @@ def is_running_systemd():
|
|||||||
def reload_supervisor():
|
def reload_supervisor():
|
||||||
supervisorctl = which("supervisorctl")
|
supervisorctl = which("supervisorctl")
|
||||||
|
|
||||||
try:
|
with contextlib.suppress(CommandFailedError):
|
||||||
# first try reread/update
|
# first try reread/update
|
||||||
exec_cmd(f"{supervisorctl} reread")
|
exec_cmd(f"{supervisorctl} reread")
|
||||||
exec_cmd(f"{supervisorctl} update")
|
exec_cmd(f"{supervisorctl} update")
|
||||||
return
|
return
|
||||||
except CommandFailedError:
|
with contextlib.suppress(CommandFailedError):
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
# something is wrong, so try reloading
|
# something is wrong, so try reloading
|
||||||
exec_cmd(f"{supervisorctl} reload")
|
exec_cmd(f"{supervisorctl} reload")
|
||||||
return
|
return
|
||||||
except CommandFailedError:
|
with contextlib.suppress(CommandFailedError):
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
# then try restart for centos
|
# then try restart for centos
|
||||||
service("supervisord", "restart")
|
service("supervisord", "restart")
|
||||||
return
|
return
|
||||||
except CommandFailedError:
|
with contextlib.suppress(CommandFailedError):
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
# else try restart for ubuntu / debian
|
# else try restart for ubuntu / debian
|
||||||
service("supervisor", "restart")
|
service("supervisor", "restart")
|
||||||
return
|
return
|
||||||
except CommandFailedError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def reload_nginx():
|
def reload_nginx():
|
||||||
try:
|
exec_cmd(f"sudo {which('nginx')} -t")
|
||||||
exec_cmd(f"sudo {which('nginx')} -t")
|
|
||||||
except Exception:
|
|
||||||
raise
|
|
||||||
|
|
||||||
service("nginx", "reload")
|
service("nginx", "reload")
|
||||||
|
Loading…
Reference in New Issue
Block a user