Author: justi9
Date: 2008-12-04 14:42:44 -0500 (Thu, 04 Dec 2008)
New Revision: 2924
Added:
mgmt/trunk/mint/bin/mint-server
Modified:
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/tools.py
mgmt/trunk/mint/python/mint/__init__.py
mgmt/trunk/mint/python/mint/tools.py
mgmt/trunk/mint/python/mint/update.py
Log:
Make mint run out of process by default
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-12-03 22:26:35 UTC (rev 2923)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-12-04 19:42:44 UTC (rev 2924)
@@ -20,9 +20,13 @@
class CuminModel(object):
def __init__(self, app, data_uri):
self.app = app
- self.data = MintModel(data_uri, dbExpireFrequency=app.config.expire_frequency, \
- dbExpireThreshold=app.config.expire_threshold, debug=False)
+ self.data = MintModel(data_uri,
+ dbExpireFrequency=app.config.expire_frequency,
+ dbExpireThreshold=app.config.expire_threshold,
+ debug=False)
+ self.data.updateObjects = False
+
self.classes = list()
self.invocations = set()
Modified: mgmt/trunk/cumin/python/cumin/tools.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/tools.py 2008-12-03 22:26:35 UTC (rev 2923)
+++ mgmt/trunk/cumin/python/cumin/tools.py 2008-12-04 19:42:44 UTC (rev 2924)
@@ -1,4 +1,4 @@
-import sys, os, re
+import sys, os, re, signal
from parsley.config import *
from parsley.command import *
@@ -6,6 +6,7 @@
from mint import *
from getpass import getpass
from psycopg2 import IntegrityError
+from subprocess import Popen
from util import *
from cumin import Cumin, CuminServer, CuminConfig
@@ -432,6 +433,21 @@
opt = CommandOption(self, "ssl")
opt.description = "Serve web pages using SSL"
+ def start_mint_process(self, config, opts):
+ args = ["mint-server",
+ "--data", self.config.data,
+ "--log-file", self.config.log_file,
+ "--log-level", self.config.log_level,
+ "--expire-frequency", str(self.config.expire_frequency),
+ "--expire-threshold", str(self.config.expire_threshold)]
+
+ if "debug" in opts or config.debug:
+ args.append("--debug")
+
+ pop = Popen(args)
+
+ return pop.pid
+
def do_run(self, opts, args):
self.config.load_dict(opts)
@@ -468,14 +484,24 @@
log.error("SSL key file '%s' not found" % kpath)
sys.exit(1)
+ mint_pid = None
+
try:
app.start()
try:
+ mint_pid = self.start_mint_process(self.config, opts)
+ except:
+ log.exception("Failed starting mint process")
+
+ try:
server.start()
finally:
server.stop()
finally:
+ if mint_pid is not None:
+ os.kill(mint_pid, signal.SIGTERM)
+
app.stop()
class CuminTestTool(BaseCuminTool):
Added: mgmt/trunk/mint/bin/mint-server
===================================================================
--- mgmt/trunk/mint/bin/mint-server (rev 0)
+++ mgmt/trunk/mint/bin/mint-server 2008-12-04 19:42:44 UTC (rev 2924)
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import sys, os, logging
+
+from mint.tools import MintServerTool
+
+def main():
+ root = logging.getLogger("mint")
+ root.setLevel(logging.DEBUG)
+
+ h = logging.StreamHandler()
+ h.setLevel(logging.DEBUG)
+ root.addHandler(h)
+
+ MintServerTool("mint-server").main()
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
Property changes on: mgmt/trunk/mint/bin/mint-server
___________________________________________________________________
Name: svn:executable
+ *
Modified: mgmt/trunk/mint/python/mint/__init__.py
===================================================================
--- mgmt/trunk/mint/python/mint/__init__.py 2008-12-03 22:26:35 UTC (rev 2923)
+++ mgmt/trunk/mint/python/mint/__init__.py 2008-12-04 19:42:44 UTC (rev 2924)
@@ -311,7 +311,7 @@
self.__lock = RLock()
self.dbConn = None
- self.mgmtSession = qmf.console.Session(self, manageConnections=True)
+ self.qmfSession = None
self.updateThread = update.ModelUpdateThread(self)
self.dbExpireThread = dbexpire.DBExpireThread \
@@ -340,6 +340,11 @@
def init(self):
sqlhub.processConnection = self.dbConn = connectionForURI(self.dataUri)
+ assert self.qmfSession is None
+
+ self.qmfSession = qmf.console.Session \
+ (self, manageConnections=True, rcvObjects=self.updateObjects)
+
def start(self):
self.updateThread.start()
self.dbExpireThread.start()
@@ -357,7 +362,7 @@
finally:
self.unlock()
- seq = self.mgmtSession._sendMethodRequest \
+ seq = self.qmfSession._sendMethodRequest \
(broker.qmfBroker, ClassKey(classKey), objId, methodName, args)
if seq is not None:
@@ -373,7 +378,7 @@
self.lock()
try:
- qbroker = self.mgmtSession.addBroker(url)
+ qbroker = self.qmfSession.addBroker(url)
mbroker = MintBroker(url, qbroker)
# Can't add the by-id mapping here, as the id is not set yet;
@@ -393,7 +398,7 @@
self.lock()
try:
- self.mgmtSession.delBroker(mbroker.qmfBroker)
+ self.qmfSession.delBroker(mbroker.qmfBroker)
del self.mintBrokersByQmfBroker[mbroker.qmfBroker]
del self.mintBrokersById[mbroker.qmfId]
Modified: mgmt/trunk/mint/python/mint/tools.py
===================================================================
--- mgmt/trunk/mint/python/mint/tools.py 2008-12-03 22:26:35 UTC (rev 2923)
+++ mgmt/trunk/mint/python/mint/tools.py 2008-12-04 19:42:44 UTC (rev 2924)
@@ -69,6 +69,35 @@
self.init()
self.run()
+class MintServerTool(BaseMintTool):
+ def __init__(self, name):
+ super(MintServerTool, self).__init__(name)
+
+ def init(self):
+ super(MintServerTool, self).init()
+
+ def do_run(self, opts, args):
+ ddef = "postgresql://cumin@localhost/cumin"
+ freqDefault = 600 # 10 minutes
+ thresholdDefault = 24 * 3600 # 1 day
+ model = MintModel(opts.get("data", ddef),
+ int(opts.get("expire-frequency", freqDefault)),
+ int(opts.get("expire-threshold", thresholdDefault)),
+ debug=True)
+
+ model.check()
+ model.init()
+ model.start()
+
+ try:
+ for arg in args[1:]:
+ model.addBroker(arg)
+
+ while True:
+ sleep(2)
+ finally:
+ model.stop()
+
class MintBenchTool(BaseMintTool):
def __init__(self, name):
super(MintBenchTool, self).__init__(name)
@@ -80,8 +109,10 @@
ddef = "postgresql://cumin@localhost/cumin"
freqDefault = 600 # 10 minutes
thresholdDefault = 24 * 3600 # 1 day
- model = MintModel(opts.get("data", ddef),
opts.get("expire-frequency", freqDefault), \
- opts.get("expire-threshold", thresholdDefault),
debug=True)
+ model = MintModel(opts.get("data", ddef),
+ int(opts.get("expire-frequency", freqDefault)),
+ int(opts.get("expire-threshold", thresholdDefault)),
+ debug=True)
model.check()
model.init()
Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py 2008-12-03 22:26:35 UTC (rev 2923)
+++ mgmt/trunk/mint/python/mint/update.py 2008-12-04 19:42:44 UTC (rev 2924)
@@ -273,8 +273,6 @@
pass
def processBroker(self, cursor, id):
- print "self.broker.databaseId", self.broker.databaseId
-
if self.broker.databaseId is None:
op = SqlGetBrokerRegistration()
op.execute(cursor, {"url": self.broker.url})