From aff7d427171cdab92e01c2d77ae87aa53dd8d6fb Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 18 Nov 2014 17:26:37 +0530 Subject: [PATCH 1/2] add patch to fix perms --- bench/cli.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/bench/cli.py b/bench/cli.py index 097d8028..42b6636b 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -23,6 +23,7 @@ import sys import logging import copy import pwd +import grp logger = logging.getLogger('bench') @@ -385,7 +386,35 @@ def _patch_mariadb_config(): repo_dir = os.path.dirname(__file__) exec_cmd(os.path.join(repo_dir, 'patches', 'fix-mariadb.sh'), cwd=os.path.join(repo_dir, 'patches')) +@click.command('fix-perms') +def _fix_perms(): + "Fix permissions if supervisor processes were run as root" + files = [ + "logs/web.error.log", + "logs/web.log", + "logs/workerbeat.error.log", + "logs/workerbeat.log", + "logs/worker.error.log", + "logs/worker.log", + "config/nginx.conf", + "logs/supervisor.conf", + ] + + frappe_user = get_config().get('frappe_user') + if not frappe_user: + print "frappe user not set" + sys.exit(1) + + for path in files: + if os.path.exists(path): + uid = pwd.getpwnam(frappe_user).pw_uid + gid = grp.getgrnam(frappe_user).gr_gid + os.chown(path, uid, gid) + + exec_cmd("{bench} setup supervisor".format(bench=sys.argv[0])) + patch.add_command(_patch_mariadb_config) +patch.add_command(_fix_perms) #Bench commands From 720c1bc0a12f43bc337820b3aa3f3ec586107e9e Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 18 Nov 2014 17:33:36 +0530 Subject: [PATCH 2/2] fix fix permissions patch --- bench/cli.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bench/cli.py b/bench/cli.py index 42b6636b..9dcb8707 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -388,6 +388,9 @@ def _patch_mariadb_config(): @click.command('fix-perms') def _fix_perms(): + if os.path.exists("config/supervisor.conf"): + exec_cmd("supervisorctl stop frappe:") + "Fix permissions if supervisor processes were run as root" files = [ "logs/web.error.log", @@ -397,7 +400,7 @@ def _fix_perms(): "logs/worker.error.log", "logs/worker.log", "config/nginx.conf", - "logs/supervisor.conf", + "config/supervisor.conf", ] frappe_user = get_config().get('frappe_user') @@ -411,7 +414,10 @@ def _fix_perms(): gid = grp.getgrnam(frappe_user).gr_gid os.chown(path, uid, gid) - exec_cmd("{bench} setup supervisor".format(bench=sys.argv[0])) + if os.path.exists("config/supervisor.conf"): + exec_cmd("{bench} setup supervisor".format(bench=sys.argv[0])) + exec_cmd("supervisorctl reload") + patch.add_command(_patch_mariadb_config) patch.add_command(_fix_perms)