From bd9ae078653147fad05a16a8ce84499c310fa70b Mon Sep 17 00:00:00 2001 From: Vitaly Kuznetsov Date: Tue, 13 Mar 2012 11:47:01 +0000 Subject: [PATCH 1/3] Revert "Add all master processes to pidfile" This reverts commit da2df290288f63150c3050f59df36fe83b1d1efd. Conflicts: salt/__init__.py --- salt/__init__.py | 3 ++- salt/master.py | 4 ---- salt/utils/__init__.py | 12 ------------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/salt/__init__.py b/salt/__init__.py index fd05304e22..ec4fac5497 100644 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -29,7 +29,8 @@ class Master(object): # command line overrides config if self.cli['user']: self.opts['user'] = self.cli['user'] - # Send the pidfile location to the opts + + # Send the pidfile location to the opts if self.cli['pidfile']: self.opts['pidfile'] = self.cli['pidfile'] diff --git a/salt/master.py b/salt/master.py index f987ade8c0..cce27e0702 100644 --- a/salt/master.py +++ b/salt/master.py @@ -131,7 +131,6 @@ class Master(SMaster): ''' Clean out the old jobs ''' - salt.utils.append_pid(self.opts['pidfile']) while True: cur = "{0:%Y%m%d%H}".format(datetime.datetime.now()) @@ -207,7 +206,6 @@ class Publisher(multiprocessing.Process): ''' Bind to the interface specified in the configuration file ''' - salt.utils.append_pid(self.opts['pidfile']) context = zmq.Context(1) pub_sock = context.socket(zmq.PUB) pull_sock = context.socket(zmq.PULL) @@ -286,7 +284,6 @@ class ReqServer(object): ''' Start up the ReqServer ''' - salt.utils.append_pid(self.opts['pidfile']) self.__bind() @@ -376,7 +373,6 @@ class MWorker(multiprocessing.Process): ''' Start a Master Worker ''' - salt.utils.append_pid(self.opts['pidfile']) self.__bind() diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 0fcf0cda91..d0e7702c0b 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -81,18 +81,6 @@ def get_colors(use=True): return colors -def append_pid(pidfile): - ''' - Save the pidfile - ''' - try: - open(pidfile, 'a').write('\n{0}'.format(str(os.getpid()))) - except IOError: - err = ('Failed to commit the pid to location {0}, please verify' - ' that the location is available').format(pidfile) - log.error(err) - - def daemonize(): ''' Daemonize a process From d9e744e1c389a79daf4ac7962e757dd9301eaa94 Mon Sep 17 00:00:00 2001 From: Vitaly Kuznetsov Date: Wed, 14 Mar 2012 11:41:11 +0000 Subject: [PATCH 2/3] If we switch to another user pidfiles must be written from original one (possibly root) as pidfiles in /var/run are usually owned by this original user. --- salt/__init__.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/salt/__init__.py b/salt/__init__.py index ec4fac5497..61b98e3f9b 100644 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -98,14 +98,14 @@ class Master(object): import logging log = logging.getLogger(__name__) # Late import so logging works correctly + import salt.master + master = salt.master.Master(self.opts) + if self.cli['daemon']: + # Late import so logging works correctly + import salt.utils + salt.utils.daemonize() + set_pidfile(self.opts['pidfile']) if check_user(self.opts['user'], log): - import salt.master - master = salt.master.Master(self.opts) - if self.cli['daemon']: - # Late import so logging works correctly - import salt.utils - salt.utils.daemonize() - set_pidfile(self.opts['pidfile']) try: master.start() except salt.master.MasterExit: @@ -187,13 +187,13 @@ class Minion(object): # Late import so logging works correctly import salt.minion log = logging.getLogger(__name__) + if self.cli['daemon']: + # Late import so logging works correctly + import salt.utils + salt.utils.daemonize() + set_pidfile(self.cli['pidfile']) if check_user(self.opts['user'], log): try: - if self.cli['daemon']: - # Late import so logging works correctly - import salt.utils - salt.utils.daemonize() - set_pidfile(self.cli['pidfile']) minion = salt.minion.Minion(self.opts) minion.tune_in() except KeyboardInterrupt: @@ -304,14 +304,14 @@ class Syndic(object): # Late import so logging works correctly import salt.minion log = logging.getLogger(__name__) + if self.cli['daemon']: + # Late import so logging works correctly + import salt.utils + salt.utils.daemonize() + set_pidfile(self.cli['pidfile']) if check_user(self.opts['user'], log): try: syndic = salt.minion.Syndic(self.opts) - if self.cli['daemon']: - # Late import so logging works correctly - import salt.utils - salt.utils.daemonize() - set_pidfile(self.cli['pidfile']) syndic.tune_in() except KeyboardInterrupt: log.warn('Stopping the Salt Syndic Minion') From eaa0c5ec921619418273c37118e09c5d9d4b6de2 Mon Sep 17 00:00:00 2001 From: David Boucha Date: Wed, 14 Mar 2012 11:40:37 -0600 Subject: [PATCH 3/3] Fix small typo --- doc/ref/file_server/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/file_server/index.rst b/doc/ref/file_server/index.rst index 261036bcc3..5c5358eda3 100644 --- a/doc/ref/file_server/index.rst +++ b/doc/ref/file_server/index.rst @@ -6,7 +6,7 @@ Salt comes with a simple file server suitable for distributing files to the salt minions. The file server is a stateless ZeroMQ server that is built into the salt master. -The main intent of the Salt File server is the present files for use in the +The main intent of the Salt File server is to present files for use in the Salt state system. With this said, the Salt file server can be used for any general file transfer from the master to the minions.