From 286fac3f7c580dfc137ac11290a2ba5713f69472 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 22 Dec 2014 20:06:20 -0500 Subject: Remove huge amounts of now unnecessary file boilerplate. --- src/mailman/commands/cli_control.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/mailman/commands/cli_control.py') diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py index b0afc1337..2febe08e5 100644 --- a/src/mailman/commands/cli_control.py +++ b/src/mailman/commands/cli_control.py @@ -15,11 +15,8 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -"""Module stuff.""" +"""Start/stop/reopen/restart commands.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Reopen', 'Restart', @@ -34,12 +31,11 @@ import errno import signal import logging -from zope.interface import implementer - from mailman.bin.master import WatcherState, master_state from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer qlog = logging.getLogger('mailman.runner') -- cgit v1.2.3-70-g09d2 From 27e7d553d29e5a547d8164b658f5e8881b026cb2 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 2 Jan 2015 10:19:52 -0500 Subject: Fix the passing of certain essential environment variables down from the `mailman` foreground command, through the `master` command and to the `runner` command. Specifically, to ensure that all agree on $VAR_DIR, we ahve to set MAILMAN_VAR_DIR in the environment that `runner` gets. Also, so that all agree on the same configuration, always pass -C pointing explicitly to the cfg file that the `mailman` command sees. --- src/mailman/bin/master.py | 15 +++++++++++---- src/mailman/commands/cli_control.py | 9 +++++---- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src/mailman/commands/cli_control.py') diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py index 6dc2a451f..e7efdc537 100644 --- a/src/mailman/bin/master.py +++ b/src/mailman/bin/master.py @@ -353,7 +353,7 @@ class Loop: # Set the environment variable which tells the runner that it's # running under bin/master control. This subtly changes the error # behavior of bin/runner. - os.environ['MAILMAN_UNDER_MASTER_CONTROL'] = '1' + env = {'MAILMAN_UNDER_MASTER_CONTROL': '1'} # Craft the command line arguments for the exec() call. rswitch = '--runner=' + spec # Wherever master lives, so too must live the runner script. @@ -361,14 +361,21 @@ class Loop: # config.PYTHON, which is the absolute path to the Python interpreter, # must be given as argv[0] due to Python's library search algorithm. args = [sys.executable, sys.executable, exe, rswitch] - if self._config_file is not None: - args.extend(['-C', self._config_file]) + # Always pass the explicit path to the configuration file to the + # sub-runners. This avoids any debate about which cfg file is used. + config_file = (config.filename if self._config_file is None + else self._config_file) + args.extend(['-C', config_file]) log = logging.getLogger('mailman.runner') log.debug('starting: %s', args) + # We must pass this environment variable through if it's set, + # otherwise runner processes will not have the correct VAR_DIR. + var_dir = os.environ.get('MAILMAN_VAR_DIR') + if var_dir is not None: + env['MAILMAN_VAR_DIR'] = var_dir # For the testing framework, if this environment variable is set, pass # it on to the subprocess. coverage_env = os.environ.get('COVERAGE_PROCESS_START') - env = dict() if coverage_env is not None: env['COVERAGE_PROCESS_START'] = coverage_env args.append(env) diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py index 2febe08e5..de3542106 100644 --- a/src/mailman/commands/cli_control.py +++ b/src/mailman/commands/cli_control.py @@ -120,8 +120,8 @@ class Start: # subprocesses to calculate their path to the $VAR_DIR. Before we # chdir() though, calculate the absolute path to the configuration # file. - config_path = (os.path.abspath(args.config) - if args.config else None) + config_path = (config.filename if args.config is None + else os.path.abspath(args.config)) os.environ['MAILMAN_VAR_DIR'] = config.VAR_DIR os.chdir(config.VAR_DIR) # Exec the master watcher. @@ -131,8 +131,9 @@ class Start: ] if args.force: execl_args.append('--force') - if config_path: - execl_args.extend(['-C', config_path]) + # Always pass the config file path to the master projects, so there's + # no confusion about which cfg is being used. + execl_args.extend(['-C', config_path]) qlog.debug('starting: %s', execl_args) os.execl(*execl_args) # We should never get here. -- cgit v1.2.3-70-g09d2