mirror of
https://github.com/frappe/bench.git
synced 2025-02-03 11:28:24 +00:00
modifications to setup production for systemd
This commit is contained in:
parent
ba5165ebbb
commit
f62341dee9
@ -1,9 +1,17 @@
|
|||||||
from bench.utils import get_program, exec_cmd, get_cmd_output, fix_prod_setup_perms, get_bench_name, find_executable, CommandFailedError
|
from bench.utils import get_program, exec_cmd, get_cmd_output, fix_prod_setup_perms, get_bench_name, find_executable, CommandFailedError
|
||||||
from bench.config.supervisor import generate_supervisor_config
|
from bench.config.supervisor import generate_supervisor_config
|
||||||
|
from bench.config.systemd import generate_systemd_config
|
||||||
from bench.config.nginx import make_nginx_conf
|
from bench.config.nginx import make_nginx_conf
|
||||||
|
from bench.config.common_site_config import get_config
|
||||||
import os, subprocess
|
import os, subprocess
|
||||||
|
|
||||||
def setup_production(user, bench_path='.', yes=False):
|
def setup_production(user, bench_path='.', yes=False):
|
||||||
|
if get_config(bench_path).get('restart_supervisor_on_update') and get_config(bench_path).get('restart_systemd_on_update'):
|
||||||
|
raise Exception("You cannot use supervisor and systemd at the same time. Modify your common_site_config accordingly." )
|
||||||
|
|
||||||
|
if get_config(bench_path).get('restart_systemd_on_update'):
|
||||||
|
generate_systemd_config(bench_path=bench_path, user=user, yes=yes)
|
||||||
|
else:
|
||||||
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
|
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
|
||||||
make_nginx_conf(bench_path=bench_path, yes=yes)
|
make_nginx_conf(bench_path=bench_path, yes=yes)
|
||||||
fix_prod_setup_perms(bench_path, frappe_user=user)
|
fix_prod_setup_perms(bench_path, frappe_user=user)
|
||||||
@ -12,6 +20,7 @@ def setup_production(user, bench_path='.', yes=False):
|
|||||||
bench_name = get_bench_name(bench_path)
|
bench_name = get_bench_name(bench_path)
|
||||||
nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name)
|
nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name)
|
||||||
|
|
||||||
|
if get_config(bench_path).get('restart_supervisor_on_update'):
|
||||||
supervisor_conf_extn = "ini" if is_centos7() else "conf"
|
supervisor_conf_extn = "ini" if is_centos7() else "conf"
|
||||||
supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format(
|
supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format(
|
||||||
bench_name=bench_name, extn=supervisor_conf_extn))
|
bench_name=bench_name, extn=supervisor_conf_extn))
|
||||||
@ -23,6 +32,7 @@ def setup_production(user, bench_path='.', yes=False):
|
|||||||
if not os.path.islink(nginx_conf):
|
if not os.path.islink(nginx_conf):
|
||||||
os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf)
|
os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf)
|
||||||
|
|
||||||
|
if get_config(bench_path).get('restart_supervisor_on_update'):
|
||||||
reload_supervisor()
|
reload_supervisor()
|
||||||
|
|
||||||
if os.environ.get('NO_SERVICE_RESTART'):
|
if os.environ.get('NO_SERVICE_RESTART'):
|
||||||
@ -41,6 +51,7 @@ def disable_production(bench_path='.'):
|
|||||||
if os.path.islink(supervisor_conf):
|
if os.path.islink(supervisor_conf):
|
||||||
os.unlink(supervisor_conf)
|
os.unlink(supervisor_conf)
|
||||||
|
|
||||||
|
if get_config(bench_path).get('restart_supervisor_on_update'):
|
||||||
exec_cmd('sudo supervisorctl reread')
|
exec_cmd('sudo supervisorctl reread')
|
||||||
exec_cmd('sudo supervisorctl update')
|
exec_cmd('sudo supervisorctl update')
|
||||||
|
|
||||||
|
@ -42,4 +42,5 @@ def generate_supervisor_config(bench_path, user=None, yes=False):
|
|||||||
f.write(config)
|
f.write(config)
|
||||||
|
|
||||||
update_config({'restart_supervisor_on_update': True}, bench_path=bench_path)
|
update_config({'restart_supervisor_on_update': True}, bench_path=bench_path)
|
||||||
|
update_config({'restart_systemd_on_update': False}, bench_path=bench_path)
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ def generate_systemd_config(bench_path, user=None, yes=False,
|
|||||||
setup_redis_config(bench_info, bench_path)
|
setup_redis_config(bench_info, bench_path)
|
||||||
|
|
||||||
update_config({'restart_systemd_on_update': True}, bench_path=bench_path)
|
update_config({'restart_systemd_on_update': True}, bench_path=bench_path)
|
||||||
|
update_config({'restart_supervisor_on_update': False}, bench_path=bench_path)
|
||||||
|
|
||||||
def setup_systemd_directory(bench_path):
|
def setup_systemd_directory(bench_path):
|
||||||
if not os.path.exists(os.path.join(bench_path, 'config', 'systemd')):
|
if not os.path.exists(os.path.join(bench_path, 'config', 'systemd')):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user