[Checkins] SVN: zc.recipe.rhrc/trunk/ New Feature
Jim Fulton
jim at zope.com
Wed May 26 11:42:56 EDT 2010
Log message for revision 112731:
New Feature
A new independent-processes option causes multiple processes to be
restarted independently, rather then stoping all of the and the
starting all of them.
Changed:
U zc.recipe.rhrc/trunk/README.txt
U zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt
U zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py
U zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/tests.py
-=-
Modified: zc.recipe.rhrc/trunk/README.txt
===================================================================
--- zc.recipe.rhrc/trunk/README.txt 2010-05-26 15:09:18 UTC (rev 112730)
+++ zc.recipe.rhrc/trunk/README.txt 2010-05-26 15:42:56 UTC (rev 112731)
@@ -16,7 +16,11 @@
New Features
------------
+- A new independent-processes option causes multiple processes to be
+ restarted independently, rather then stoping all of the and the
+ starting all of them.
+
Bugs Fixed
----------
Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt 2010-05-26 15:09:18 UTC (rev 112730)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt 2010-05-26 15:42:56 UTC (rev 112731)
@@ -575,6 +575,100 @@
The individual scripts don't have chkconfig information.
+Independent processes
+---------------------
+
+Normally, processes are assumed to be dependent and are started in
+order, stopped in referese order, and, on restart, are all stopped and
+then all started.
+
+If the independent-processes option is used, then the generated master
+run script will treat the processes as independent and restart
+processed individually. With lots of independent processes, this can
+reduce the amount of time individual processes are down.
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = zoperc
+ ...
+ ... [zoperc]
+ ... recipe = zc.recipe.rhrc
+ ... parts = instance1 instance2
+ ... dest = %(dest)s
+ ... chkconfig = 345 90 10
+ ... chkconfigcommand = echo
+ ... user = zope
+ ... independent-processes = true
+ ...
+ ... [instance1]
+ ... run-script = /opt/zope/bin/zopectl -C /etc/instance1.conf
+ ... env = LD_LIBRARY_PATH=/opt/foolib
+ ...
+ ... [instance2]
+ ... """ % dict(dest=demo))
+
+ >>> print system('bin/buildout'),
+ Uninstalling zoperc.
+ Running uninstall recipe.
+ --del zoperc
+ Installing zoperc.
+ --add zoperc
+
+ >>> cat(demo, 'zoperc')
+ #!/bin/sh
+ <BLANKLINE>
+ # the next line is for chkconfig
+ # chkconfig: 345 90 10
+ # description: please, please work
+ <BLANKLINE>
+ <BLANKLINE>
+ if [ $(whoami) != "root" ]; then
+ echo "You must be root."
+ exit 1
+ fi
+ <BLANKLINE>
+ LD_LIBRARY_PATH=/opt/foolib \
+ su zope -c \
+ "/opt/zope/bin/zopectl -C /etc/instance1.conf $*" \
+ </dev/null
+ <BLANKLINE>
+ echo instance2:
+ /demo/instance2 "$@" \
+ </dev/null
+
+.. check validation
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = zoperc
+ ...
+ ... [zoperc]
+ ... recipe = zc.recipe.rhrc
+ ... parts = instance1 instance2
+ ... dest = %(dest)s
+ ... chkconfig = 345 90 10
+ ... chkconfigcommand = echo
+ ... user = zope
+ ... independent-processes = yes
+ ...
+ ... [instance1]
+ ... run-script = /opt/zope/bin/zopectl -C /etc/instance1.conf
+ ... env = LD_LIBRARY_PATH=/opt/foolib
+ ...
+ ... [instance2]
+ ... """ % dict(dest=demo))
+
+ >>> print system('bin/buildout'),
+ zc.recipe.rhrc: Invalid value for independent-processes. Use 'true' or 'false'
+ While:
+ Installing.
+ Getting section zoperc.
+ Initializing part zoperc.
+ Error: Invalid value for independent-processes: yes
+
+
Deployments
-----------
Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py 2010-05-26 15:09:18 UTC (rev 112730)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py 2010-05-26 15:42:56 UTC (rev 112731)
@@ -38,6 +38,14 @@
options['envs'] = '\n'.join([buildout[part].get('env', '')
for part in options['parts'].split()
])
+ independent = options.get('independent-processes')
+ if independent:
+ if independent not in ('true', 'false'):
+ logger.error(
+ "Invalid value for independent-processes. "
+ " Use 'true' or 'false'")
+ raise zc.buildout.UserError(
+ 'Invalid value for independent-processes:', independent)
def install(self):
options = self.options
@@ -99,7 +107,10 @@
script = '\n\n '.join(cooked)
cooked.reverse()
rscript = '\n\n '.join(cooked)
- self.output(chkconfig, script, name, created, rscript)
+ self.output(
+ chkconfig, script, name, created, rscript,
+ independent=options.get('independent-processes') == 'true',
+ )
return created
except:
[os.remove(f) for f in created]
@@ -122,17 +133,27 @@
return script + ' "$@"'
- def output(self, chkconfig, script, ctl, created, rscript=None):
- if rscript is None:
- rscript = script
- rc = rc_template % dict(
- rootcheck = self.options.get('user') and rootcheck or '',
- CHKCONFIG = (chkconfig
- and (chkconfig_template % chkconfig)
- or non_chkconfig_template),
- CTL_SCRIPT = script,
- CTL_SCRIPT_R = rscript,
- )
+ def output(self, chkconfig, script, ctl, created,
+ rscript=None, independent=False):
+ if independent:
+ rc = independent_template % dict(
+ rootcheck = self.options.get('user') and rootcheck or '',
+ CHKCONFIG = (chkconfig
+ and (chkconfig_template % chkconfig)
+ or non_chkconfig_template),
+ CTL_SCRIPT = script,
+ )
+ else:
+ if rscript is None:
+ rscript = script
+ rc = rc_template % dict(
+ rootcheck = self.options.get('user') and rootcheck or '',
+ CHKCONFIG = (chkconfig
+ and (chkconfig_template % chkconfig)
+ or non_chkconfig_template),
+ CTL_SCRIPT = script,
+ CTL_SCRIPT_R = rscript,
+ )
dest = self.options.get('dest', '/etc/init.d')
ctlpath = os.path.join(dest, ctl)
open(ctlpath, 'w').write(rc)
@@ -197,3 +218,10 @@
esac
"""
+
+independent_template = """#!/bin/sh
+
+%(CHKCONFIG)s
+%(rootcheck)s
+ %(CTL_SCRIPT)s
+"""
Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/tests.py
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/tests.py 2010-05-26 15:09:18 UTC (rev 112730)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/tests.py 2010-05-26 15:42:56 UTC (rev 112731)
@@ -12,14 +12,13 @@
#
##############################################################################
-import re, unittest
-from zope.testing import doctest, renormalizing
+import doctest, re, unittest
+from zope.testing import renormalizing
import zc.buildout.testing
def setUp(test):
zc.buildout.testing.buildoutSetUp(test)
zc.buildout.testing.install_develop('zc.recipe.rhrc', test)
-
def test_suite():
return unittest.TestSuite((
@@ -32,5 +31,4 @@
zc.buildout.testing.normalize_egg_py,
])
),
-
))
More information about the checkins
mailing list