Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install plone.recipe.cluster

How to install plone.recipe.cluster

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install plone.recipe.cluster
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0.0rc1 Available View build log
Windows (64-bit)
1.0.0rc1 Available View build log
Mac OS X (10.5+)
1.0.0rc1 Available View build log
Linux (32-bit)
1.0.0rc1 Available View build log
Linux (64-bit)
1.0.0rc1 Available View build log
 
Author
License
ZPL
Lastest release
version 1.0.0rc1 on Jan 5th, 2011

Code repository: http://svn.plone.org/svn/collective/buildout/plone.recipe.cluster/

Change history

1.0.0rc1 (2010-03-18)
  • Now, you can securely launch cluster from many (init.d script, fabric method, etc) :

System Message: WARNING/2 (<string>, line 13)

Bullet list ends without a blank line; unexpected unindent.

default pid file location is in buildout/var directory [tdesvenain]

  • Now you can easily have many clusters in your buildout :

System Message: WARNING/2 (<string>, line 16)

Bullet list ends without a blank line; unexpected unindent.

pid filename depends on cluster part name [tdesvenain]

  • make tests pass with latest zc.buildout versions (> 1.1.1) [tdesvenain]
0.1.0 (unreleased)
  • Initial implementation of Linux daemon.

System Message: WARNING/2 (<string>, line 24)

Bullet list ends without a blank line; unexpected unindent.

[tarek]

  • Created recipe with ZopeSkel.

System Message: WARNING/2 (<string>, line 27)

Bullet list ends without a blank line; unexpected unindent.

[tarek]

Detailed Documentation

Supported options

The recipe supports the following options:

debug default option is 0. When set to 1, allows tests to run on a non-blocking daemon.

start Multiline option. Each line is a command line that will be called by the daemon when it is called with the start option. The commands must return immediatly, because the daemon waits for it before it launches the next command.

It is possible though, to push a command line in the background with the background: prefix.

stop Multiline option. Each line is a command line that will be called by the daemon when it is called with the stop option. The commands must return immediatly, because the daemon waits for it before it launches the next command.

It is possible to ask the daemon to kill a given process, by providing a pid:value command line. Where value is either a PID number, either a text files that contains a pid.

The background: prefix is also available.

restart Multiline option. Each line is a command line that will be called by the daemon when it is called with the restart option. The commands must return immediatly, because the daemon waits for it before it launches the next command.

It is possible to ask the daemon to kill a given process, by providing a pid:value command line. Where value is either a PID number, either a text files that contains a pid.

The background: prefix is also available.

pid-file Defines the path to the PID file of the daemon.

Example usage

The cluster recipe allows you to create composite commands for your buildout. There are three commands:

  • start
  • stop
  • restart

Each command is a variable with a list of commands to be run. The recipe then launches: - a daemon under Linux based system - a NT service under Windows

A typical usage for instance is to start zeo, zope and pound:

[buildout]

...

[cluster] recipe = plone.recipe.cluster

poundctl = ${buildout:bin-directory}/pound -f ${buildout:directory}/parts/pound/etc/pound.cfg -c ${buildout:directory}/pound.pid

start = ${buildout:bin-directory}/zeoserver start ${buildout:bin-directory}/instance start ${cluster:poundctl}

stop = ${buildout:bin-directory}/zeoserver stop ${buildout:bin-directory}/instance stop pid:${buildout:directory}/pound.pid

restart = ${buildout:bin-directory}/zeoserver restart ${buildout:bin-directory}/instance restart ${cluster:poundctl}

Let's try this:

>>> write('buildout.cfg',

System Message: ERROR/3 (<string>, line 122)

Inconsistent literal block quoting.

... """ ... [buildout] ... parts = mycluster ... index = http://pypi.python.org/simple ... [mycluster] ... recipe = plone.recipe.cluster ... debug = 1 ... start = ... background:${buildout:bin-directory}/script1 ... ${buildout:bin-directory}/script2 start ... ... stop = ... ${buildout:bin-directory}/script2 stop ... ... restart = ... background:${buildout:bin-directory}/script1 ... ${buildout:bin-directory}/script2 restart ... ... """)

Running the buildout gives us:

>>> print system(buildout)

System Message: ERROR/3 (<string>, line 145)

Inconsistent literal block quoting.

Getting distribution for 'zc.recipe.egg'. Got zc.recipe.egg .... Installing mycluster. Generated script '/.../bin/mycluster'. <BLANKLINE>

Now let's see the script that was created:

>>> script = join(sample_buildout, 'bin', 'mycluster')
>>> print open(script).read()

System Message: ERROR/3 (<string>, line 155)

Inconsistent literal block quoting.

#!...python... <BLANKLINE> import sys sys.path[0:0] = [ ... ] <BLANKLINE> import plone.recipe.cluster.ctl <BLANKLINE> if __name__ == '__main__': plone.recipe.cluster.ctl.main(...) <BLANKLINE>

Let's create false scripts:

>>> script2 = join(sample_buildout, 'bin', 'script2')
>>> f = open(script2, 'w')
>>> f.write('echo script 2')
>>> f.close()
>>> import os
>>> os.chmod(script2, 0770)
>>> script1 = join(sample_buildout, 'bin', 'script1')
>>> f = open(script1, 'w')
>>> import sys
>>> f.write("""\
... #!%s
... import time
... #doesnt works with zc.buildout >= 1.1.1
... #while 1:
... #   time.sleep(0.1)
... """ % sys.executable)
>>> f.close()
>>> os.chmod(script1, 0770)

Let's try to execute it:

>>> print system(script)

System Message: ERROR/3 (<string>, line 193)

Inconsistent literal block quoting.

usage: /sample-buildout/bin/mycluster start|stop|restart|status <BLANKLINE>

Let's ask for the status:

>>> print system('%s status' % script)

System Message: ERROR/3 (<string>, line 199)

Inconsistent literal block quoting.

Not running.

Ah right, let's start it !:: >>> print system('%s start' % script) Cluster is starting... Running in background ...script1 Running ...script2 start script 2 Child PIDs: ..., ... Started with pid ... Cluster is alive... <BLANKLINE>

Let's ask for the status:

>>> print system('%s status' % script)

System Message: ERROR/3 (<string>, line 216)

Inconsistent literal block quoting.

Running.

We should not be able to start it twice:: >>> os.path.exists('%s/var/mycluster.pid' % sample_buildout) True >>> print system('%s start' % script) <BLANKLINE> Start aborded since pid file '...' exists. <BLANKLINE>

Let's stop it:

>>> print system('%s stop' % script)

System Message: ERROR/3 (<string>, line 229)

Inconsistent literal block quoting.

Stopping PID ... Stopping PID ... Cluster is going down... ...

Let's restart it:

>>> print system('%s restart' % script)

System Message: ERROR/3 (<string>, line 237)

Inconsistent literal block quoting.

Could not stop, pid file '/sample-buildout/var/mycluster.pid' missing. <BLANKLINE>

Oh right, it was stopped !

Contributors

Tarek Ziade, Author

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.