1
2 """
3 Startup plugin for our various server components, called typically
4 by icegridnode after parsing etc/grid/templates.xml.
5
6 Plugin read by omero.cli.Cli during initialization. The method(s)
7 defined here will be added to the Cli class for later use.
8
9 Copyright 2008 Glencoe Software, Inc. All rights reserved.
10 Use is subject to license terms supplied in LICENSE.txt
11
12 """
13
14 import subprocess, optparse, os, sys, signal, time
15 from omero.cli import Arguments, BaseControl, VERSION
16 import omero.java
17
19
20 - def _prop(self, data, key):
22
24 try:
25 args["--Ice.Config"]
26 except KeyError:
27 self.ctx.die(201, "No --Ice.Config provided")
28 pre = []
29 post = []
30 for arg in args.args:
31 if arg.startswith("-D"):
32 pre.append(arg)
33 else:
34 post.append(arg)
35 return pre,post
36
38 component = str(component)
39 data = self.ctx.initData({})
40 xargs = self._prop(data, component+".xargs")
41 if len(xargs) == 0:
42 xargs = xargs_default
43 debug = self._prop(data, component+".debug")
44 if debug == "true":
45 debug = True
46 else:
47 debug = False
48 return xargs, debug
49
50 - def help(self, args = None):
51 self.ctx.out("Start the blitz server -- Reads properties via omero prefs")
52
54 args = Arguments(args)
55 pre, post = self._checkIceConfig(args)
56 xargs, debug = self._xargsAndDebug("blitz", ["-Xmx400M"])
57 blitz_jar = os.path.join("lib","server","blitz.jar")
58 command = pre+["-jar",blitz_jar]+post
59 omero.java.run(command, debug=debug, xargs=xargs, use_exec = True)
60
62 args = Arguments(args)
63 pre, post = self._checkIceConfig(args)
64 xargs, debug = self._xargsAndDebug("indexer", ["-Xmx256M"])
65 blitz_jar = os.path.join("lib","server","blitz.jar")
66 omero.java.run(pre+["-jar",blitz_jar,"ome.fulltext"]+post, debug=debug, xargs=xargs, use_exec = True)
67
68 - def web(self, args):
69 args = Arguments(args)
70 sys.stderr.write("Starting django... \n")
71 omero_web = self.ctx.dir / "lib" / "python" / "omeroweb"
72
73
74 os.chdir(str(omero_web))
75 django = ["python","manage.py","runserver","--noreload"]+list(args)
76 os.execvpe("python", django, os.environ)
77 try:
78 register("server", ServerControl)
79 except NameError:
80 ServerControl()._main()
81