Commits

Christian Theune  committed 27f6071

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

  • Participants
  • Parent commits 2e10d4b

Comments (0)

Files changed (7)

File components/django/buildout.cfg

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

File 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))

File components/django/startup

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

File components/memcached/component.py

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

File 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)}

File 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')

File environments/dev-ctheune.cfg

+[environment]
+host_domain =
+
+[hosts]
+localhost = django, supervisor