Christian Theune avatar Christian Theune committed 27f6071

Snapshot: work towards simple django component, copied supervisor from batou
examples.

Comments (0)

Files changed (7)

components/django/buildout.cfg

+[buildout]
+parts = app
+find-links = http://uter.gocept.com/~ctheune/.sprintfindlinks
+
+[app]
+recipe = zc.recipe.egg
+eggs = sprintsite

components/django/component.py

+from batou.component import Component
+from batou.lib.buildout import Buildout
+from batou.lib.file import File
+
+
+class Django(Component):
+
+    _hooks = {'supervisor': None}
+
+    def configure(self):
+        buildout_cfg = File('buildout.cfg', is_template=True)
+        self += Buildout(python='2.6', config=buildout_cfg)
+
+        self.hooks['supervisor'] = (
+            '30 django (startsecs=3) {0}/bin/django-admin '
+            '[runserver --settings=sprintsite.settings]'
+            .format(self.root.workdir))

components/django/startup

+PYTHONPATH=$PYTHONPATH:./sprintsite ./bin/django-admin.py runserver --pythonpath=settings --settings=settings_dev

components/memcached/component.py

+from batou.component import Component
+
+
+class Memcached(Component):
+    pass

components/supervisor/buildout.cfg

+[buildout]
+parts = supervisor
+newest = false
+
+[supervisor]
+recipe = collective.recipe.supervisor
+port = ${component.parent.http_port.listen}
+serverurl = http://${component.parent.http_port.connect}
+plugins = superlance
+logfile-maxbytes = 0
+logfile-backups = 0
+programs = ${'\n\t'.join(component.parent.programs)}

components/supervisor/component.py

+# Copyright (c) 2012 gocept gmbh & co. kg
+# See also LICENSE.txt
+
+from batou.utils import Address
+from batou.component import Component
+from batou.lib.file import File
+from batou.lib.service import Service
+from batou.lib.buildout import Buildout
+from batou import UpdateNeeded
+import os
+
+
+class Supervisor(Component):
+
+    http_port = Address('localhost:9001')
+
+    def configure(self):
+        self.programs = self.find_hooks('supervisor', self.host)
+        import pdb; pdb.set_trace() 
+        self += Buildout(
+            python='2.7',
+            config=File('buildout.cfg', is_template=True))
+        self += Service('bin/supervisord', pidfile='var/supervisor.pid')
+
+    def verify(self):
+        self.assert_file_is_current('var/supervisord.pid',
+                ['.batou.buildout.success'])
+        try:
+            self.cmd('bin/supervisorctl pid')
+        except Exception:
+            raise UpdateNeeded()
+
+    def update(self):
+        try:
+            self.cmd('bin/supervisorctl reload')
+        except:
+            self.cmd('bin/supervisord')

environments/dev-ctheune.cfg

+[environment]
+host_domain =
+
+[hosts]
+localhost = django, supervisor
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.