2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-10 00:37:51 +00:00

TODO: restart_systemd_processes

This commit is contained in:
Revant Nandgaonkar 2018-04-11 22:27:54 +05:30
parent b94a5e63b9
commit 9f7725f6ed

View File

@ -397,34 +397,35 @@ def restart_supervisor_processes(bench_path='.', web_workers=False):
exec_cmd('sudo supervisorctl restart {group}'.format(group=group), cwd=bench_path) exec_cmd('sudo supervisorctl restart {group}'.format(group=group), cwd=bench_path)
def restart_systemcd_processes(bench_path='.', web_workers=False): def restart_systemd_processes(bench_path='.', web_workers=False):
from .config.common_site_config import get_config print("Restarting . . .")
conf = get_config(bench_path=bench_path) # from .config.common_site_config import get_config
bench_name = get_bench_name(bench_path) # conf = get_config(bench_path=bench_path)
# bench_name = get_bench_name(bench_path)
cmd = conf.get('systemd_restart_cmd') # cmd = conf.get('systemd_restart_cmd')
if cmd: # if cmd:
exec_cmd(cmd, cwd=bench_path) # exec_cmd(cmd, cwd=bench_path)
else: # else:
systemd_status = subprocess.check_output(['sudo', 'systemctl', 'status'], cwd=bench_path) # systemd_status = subprocess.check_output(['sudo', 'systemctl', 'status'], cwd=bench_path)
systemd_status = safe_decode(supervisor_status) # systemd_status = safe_decode(supervisor_status)
if web_workers and '{bench_name}-web:'.format(bench_name=bench_name) in systemd_status: # if web_workers and '{bench_name}-web:'.format(bench_name=bench_name) in systemd_status:
group = '{bench_name}-web: '.format(bench_name=bench_name) # group = '{bench_name}-web: '.format(bench_name=bench_name)
elif '{bench_name}-workers:'.format(bench_name=bench_name) in systemd_status: # elif '{bench_name}-workers:'.format(bench_name=bench_name) in systemd_status:
group = '{bench_name}-workers: {bench_name}-web:'.format(bench_name=bench_name) # group = '{bench_name}-workers: {bench_name}-web:'.format(bench_name=bench_name)
# backward compatibility # # backward compatibility
elif '{bench_name}-processes:'.format(bench_name=bench_name) in systemd_status: # elif '{bench_name}-processes:'.format(bench_name=bench_name) in systemd_status:
group = '{bench_name}-processes:'.format(bench_name=bench_name) # group = '{bench_name}-processes:'.format(bench_name=bench_name)
# backward compatibility # # backward compatibility
else: # else:
group = 'frappe:' # group = 'frappe:'
exec_cmd('sudo systemctl restart {group}'.format(group=group), cwd=bench_path) # exec_cmd('sudo systemctl restart {group}'.format(group=group), cwd=bench_path)
def set_default_site(site, bench_path='.'): def set_default_site(site, bench_path='.'):
if not site in get_sites(bench_path=bench_path): if not site in get_sites(bench_path=bench_path):