summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-09-09 04:20:38 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-09-09 04:20:38 +0000
commitdd36b243507feb8a76c8b7dc99779594a2848d23 (patch)
treec850b08dae326fe11a17afdcd5fa9b025f3fa9a2 /src
parent926c2d83ef9832a687b9c5276f9c06b453f75a11 (diff)
downloadbcfg2-dd36b243507feb8a76c8b7dc99779594a2848d23.tar.gz
bcfg2-dd36b243507feb8a76c8b7dc99779594a2848d23.tar.bz2
bcfg2-dd36b243507feb8a76c8b7dc99779594a2848d23.zip
Make file monitor selectable
Handle child processes more aggressively git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4908 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Component.py4
-rw-r--r--src/lib/Options.py3
-rw-r--r--src/lib/Server/Core.py8
-rw-r--r--src/lib/Server/FileMonitor.py2
-rwxr-xr-xsrc/sbin/bcfg2-server7
5 files changed, 16 insertions, 8 deletions
diff --git a/src/lib/Component.py b/src/lib/Component.py
index 7ee2df515..aca74f7d1 100644
--- a/src/lib/Component.py
+++ b/src/lib/Component.py
@@ -212,6 +212,7 @@ class Component(TLSServer,
# need to add waitpid code here to enforce maxchild
if method in self.fork_funcs:
self.clean_up_children()
+ self.check_for_free_slot()
pid = os.fork()
if pid:
self.children.append(pid)
@@ -252,11 +253,12 @@ class Component(TLSServer,
break
except OSError:
break
+
+ def check_for_free_slot(self):
if len(self.children) >= self.child_limit:
self.logger.info("Reached child_limit; waiting for child exit")
pid = os.waitpid(0, 0)[0]
self.children.remove(pid)
- self.logger.debug("process %d exited" % pid)
def _authenticate_connection(self, method, user, password, address):
'''Authenticate new connection'''
diff --git a/src/lib/Options.py b/src/lib/Options.py
index 21cb31fdf..a158ab37d 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -186,7 +186,8 @@ SERVER_GENERATORS = Option('Server generator list', cf=('server', 'generators'),
cook=list_split)
SERVER_STRUCTURES = Option('Server structure list', cf=('server', 'structures'),
default=['Bundler', 'Base'], cook=list_split)
-
+SERVER_FILEMONITOR = Option('Server file monitor', cf=('server', 'filemonitor'),
+ default='default')
SERVER_LOCATION = Option('Server Location', cf=('components', 'bcfg2'),
default='https://localhost:6789', cmd='-S',
odesc='https://server:port')
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 5687cba9d..b29c9bf05 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -24,13 +24,15 @@ class CoreInitError(Exception):
class Core(object):
'''The Core object is the container for all Bcfg2 Server logic, and modules'''
- def __init__(self, repo, plugins, structures, generators, password, svn, encoding):
+ def __init__(self, repo, plugins, structures, generators, password, svn,
+ encoding, filemonitor='default'):
object.__init__(self)
self.datastore = repo
try:
- self.fam = Bcfg2.Server.FileMonitor.default()
+ self.fam = Bcfg2.Server.FileMonitor.available[filemonitor]()
except IOError:
- raise CoreInitError, "failed to connect to fam"
+ raise CoreInitError, "failed to instantiate fam driver (used %s)" % \
+ filemonitor
self.pubspace = {}
self.generators = []
self.structures = []
diff --git a/src/lib/Server/FileMonitor.py b/src/lib/Server/FileMonitor.py
index bb0441c65..bea210150 100644
--- a/src/lib/Server/FileMonitor.py
+++ b/src/lib/Server/FileMonitor.py
@@ -231,5 +231,5 @@ available['pseudo'] = PseudoFam
for fdrv in ['gamin', 'fam', 'pseudo']:
if fdrv in available:
- default = available[fdrv]
+ available['default'] = available[fdrv]
break
diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server
index ba438a07d..ca1565101 100755
--- a/src/sbin/bcfg2-server
+++ b/src/sbin/bcfg2-server
@@ -35,7 +35,7 @@ class Bcfg2Serv(Bcfg2.Component.Component):
try:
self.Core = Core(setup['repo'], setup['plugins'], setup['structures'],
setup['generators'], setup['password'],
- setup['svn'], setup['encoding'])
+ setup['svn'], setup['encoding'], setup['filemonitor'])
except CoreInitError, msg:
logger.critical("Fatal error: %s" % (msg))
raise SystemExit, 1
@@ -86,6 +86,7 @@ class Bcfg2Serv(Bcfg2.Component.Component):
rsockinfo = []
famfd = self.Core.fam.fileno()
while self.socket not in rsockinfo:
+ self.clean_up_children()
if self.shut:
raise socket.error
try:
@@ -202,7 +203,9 @@ if __name__ == '__main__':
'plugins': Bcfg2.Options.SERVER_PLUGINS,
'structures': Bcfg2.Options.SERVER_STRUCTURES,
'generators': Bcfg2.Options.SERVER_GENERATORS,
- 'password': Bcfg2.Options.SERVER_PASSWORD})
+ 'password': Bcfg2.Options.SERVER_PASSWORD,
+ 'filemonitor': Bcfg2.Options.SERVER_FILEMONITOR,
+ })
OPTINFO.update({'key' : Bcfg2.Options.SERVER_KEY,
'location' : Bcfg2.Options.SERVER_LOCATION,
'passwd' : Bcfg2.Options.SERVER_PASSWORD,