Permalink
Browse files

Refactoring in BaseProcess to support an onspawn hook

  • Loading branch information...
Michael Meisinger
Michael Meisinger committed Jun 4, 2010
1 parent fe64952 commit 982030b3b254720f1f85aaf9458c42e309586153
Showing with 15 additions and 6 deletions.
  1. +2 −0 README.txt
  2. +8 −1 ion/core/base_process.py
  3. +5 −5 res/scripts/newcc.py
View
@@ -123,6 +123,8 @@ Change log:
2010-06-02:
- BaseProcess self members renamed to conform to PEP8
- Added process shutdown to BaseProcess
+- Added container UNIX shell argument -a processes=<path to filename> used
+ by newcc.py script, with a list of processes to startup in standard format
2010-05-25:
- Made Cassandra backend parameterizable with keyspace/colfamily and added
SuperColumn support.
View
@@ -100,13 +100,20 @@ def spawn(self):
"""
Spawns this process using the process' receiver. Self spawn can
only be called once per instance.
- @note this method is not called when spawned by magnet
+ @note this method is not called when spawned through magnet. This makes
+ it tricky to do consistent initialization on spawn.
"""
assert not self.receiver.spawned, "Process already spawned"
self.id = yield spawn(self.receiver)
logging.debug('spawn()=' + str(self.id))
+ yield defer.maybeDeferred(self.plc_spawn)
defer.returnValue(self.id)
+ def plc_spawn(self):
+ """
+ Process life cycle event: on spawn of process (once)
+ """
+
def is_spawned(self):
return self.receiver.spawned != None
View
@@ -8,14 +8,13 @@
from ion.core import bootstrap
from ion.util.config import Config
+# Use the bootstrap configuration entries from the standard bootstrap
CONF = ioninit.config('ion.core.bootstrap')
-# Static definition of service names
+# Config files with lists of processes to start
agent_procs = ioninit.get_config('ccagent_cfg', CONF)
-
svc_procs = ioninit.get_config('services_cfg', CONF)
-
@defer.inlineCallbacks
def main():
"""
@@ -27,13 +26,14 @@ def main():
processes.extend(agent_procs)
processes.extend(svc_procs)
+ # Start the cc-agent and processes from config file
sup = yield bootstrap.bootstrap(None, processes)
+ # Start processes from config file given in arguments
procsfile = ioninit.cont_args.get('processes', None)
-
if procsfile:
procs = Config(procsfile).getObject()
- logging.info("Also starting "+str(procs))
+ logging.info("Starting local process list: "+str(procs))
yield bootstrap.spawn_processes(procs, sup=sup)
main()

0 comments on commit 982030b

Please sign in to comment.