[Checkins] SVN: zc.recipe.rhrc/trunk/ Added optional process-management support. If requested, then run
jim
cvs-admin at zope.org
Fri May 18 12:54:10 UTC 2012
Log message for revision 126065:
Added optional process-management support. If requested, then run
scripts are run as part of install and uninstall.
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
-=-
Modified: zc.recipe.rhrc/trunk/README.txt
===================================================================
--- zc.recipe.rhrc/trunk/README.txt 2012-05-18 12:51:43 UTC (rev 126064)
+++ zc.recipe.rhrc/trunk/README.txt 2012-05-18 12:54:07 UTC (rev 126065)
@@ -10,11 +10,13 @@
Changes
*******
-1.3.1 (unreleased)
+1.4.0 (2012-05-18)
==================
-- Added not declared, but needed test dependency on `zope.testing`.
+- Added optional process-management support. If requested, then run
+ scripts are run as part of install and uninstall.
+- Fixed: missing dependency on ``zope.testing``
1.3.0 (2010/05/26)
==================
Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt 2012-05-18 12:51:43 UTC (rev 126064)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt 2012-05-18 12:54:07 UTC (rev 126065)
@@ -786,7 +786,70 @@
Running uninstall recipe.
--del acme
+Process Management
+==================
+Normally, the recipe doesn't start and stop processes. If we want it
+to, we can use the process-management option with a 'true' value.
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = zoperc
+ ...
+ ... [zoperc]
+ ... recipe = zc.recipe.rhrc
+ ... parts = zope
+ ... dest = %(dest)s
+ ... process-management = true
+ ...
+ ... [zope]
+ ... run-script = echo zope
+ ... """ % dict(dest=demo))
+
+ >>> print system('bin/buildout'),
+ Installing zoperc.
+ zope start
+
+ >>> print system('bin/buildout buildout:parts='),
+ Uninstalling zoperc.
+ Running uninstall recipe.
+ zope stop
+
+.. make sure it works with multiple parts
+
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = zoperc
+ ...
+ ... [zoperc]
+ ... recipe = zc.recipe.rhrc
+ ... parts = zope zeo
+ ... dest = %(dest)s
+ ... process-management = true
+ ...
+ ... [zeo]
+ ... run-script = echo zeo
+ ...
+ ... [zope]
+ ... run-script = echo zope
+ ... """ % dict(dest=demo))
+
+ >>> print system('bin/buildout'),
+ Installing zoperc.
+ zope start
+ zeo start
+
+ >>> print system('bin/buildout buildout:parts='),
+ Uninstalling zoperc.
+ Running uninstall recipe.
+ zeo stop
+ zope stop
+
+
+
Regression Tests
================
@@ -809,8 +872,7 @@
... [zope]
... """ % dict(dest=demo))
>>> print system('bin/buildout'),
-
- Installing zoperc.
+ Installing zoperc.
zc.recipe.rhrc: Part zope doesn't define run-script and /demo/zope doesn't exist.
While:
Installing zoperc.
Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py 2012-05-18 12:51:43 UTC (rev 126064)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py 2012-05-18 12:54:07 UTC (rev 126065)
@@ -12,7 +12,11 @@
#
##############################################################################
-import logging, os, shutil, stat
+import logging
+import os
+import shutil
+import subprocess
+import stat
import zc.buildout
logger = logging.getLogger('zc.recipe.rhrc')
@@ -47,6 +51,11 @@
raise zc.buildout.UserError(
'Invalid value for independent-processes:', independent)
+ if options.get('process-management', 'false') not in (
+ 'true', 'false'):
+ raise zc.buildout.UserError('Invalid process-management option: %r'
+ % (options['process-management']))
+
def install(self):
options = self.options
name = options.get('deployment-name', self.name)
@@ -60,6 +69,7 @@
user = '' # no need to su to root
envs = options['envs'].split('\n')
created = []
+ start = self.options.get('process-management')
try:
if len(scripts) == 1:
# No mongo script
@@ -78,7 +88,8 @@
if chkconfig:
script += ' \\\n </dev/null'
- self.output(chkconfig, script, name, created)
+ self.output(chkconfig, script, name, created,
+ start=start)
else:
cooked = []
for part, env, script in zip(parts, envs, scripts):
@@ -110,6 +121,7 @@
self.output(
chkconfig, script, name, created, rscript,
independent=options.get('independent-processes') == 'true',
+ start=start,
)
return created
except:
@@ -134,7 +146,7 @@
return script + ' "$@"'
def output(self, chkconfig, script, ctl, created,
- rscript=None, independent=False):
+ rscript=None, independent=False, start=False):
if independent:
rc = independent_template % dict(
rootcheck = self.options.get('user') and rootcheck or '',
@@ -144,15 +156,13 @@
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,
+ CTL_SCRIPT_R = rscript or script,
)
dest = self.options.get('dest', '/etc/init.d')
ctlpath = os.path.join(dest, ctl)
@@ -165,11 +175,18 @@
'/sbin/chkconfig')
os.system(chkconfigcommand+' --add '+ctl)
+ if start and subprocess.call([ctlpath, 'start']):
+ raise RuntimeError("%s start failed" % ctlpath)
+
def update(self):
pass
def uninstall(name, options):
name = options.get('deployment-name', name)
+ if options.get('process-management') == 'true':
+ ctlpath = os.path.join(options.get('dest', '/etc/init.d'), name)
+ if subprocess.call([ctlpath, 'stop']):
+ raise RuntimeError("%s start failed" % ctlpath)
if options.get('chkconfig'):
chkconfigcommand = options.get('chkconfigcommand', '/sbin/chkconfig')
os.system(chkconfigcommand+' --del '+name)
More information about the checkins
mailing list