1 # copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """twisted server configurations: |
|
19 |
|
20 * the "all-in-one" configuration to get a web instance running in a twisted |
|
21 web server integrating a repository server in the same process (only available |
|
22 if the repository part of the software is installed |
|
23 """ |
|
24 |
|
25 from os.path import join |
|
26 |
|
27 from logilab.common.configuration import merge_options |
|
28 |
|
29 from cubicweb.cwconfig import CONFIGURATIONS |
|
30 from cubicweb.server.serverconfig import ServerConfiguration |
|
31 from cubicweb.web.webconfig import WebConfiguration, WebConfigurationBase |
|
32 |
|
33 |
|
34 class AllInOneConfiguration(WebConfigurationBase, ServerConfiguration): |
|
35 """repository and web instance in the same twisted process""" |
|
36 name = 'all-in-one' |
|
37 options = merge_options(( |
|
38 ('profile', |
|
39 {'type': 'string', |
|
40 'default': None, |
|
41 'help': 'profile code and use the specified file to store stats if this option is set', |
|
42 'group': 'web', 'level': 3, |
|
43 }), |
|
44 ('host', |
|
45 {'type': 'string', |
|
46 'default': None, |
|
47 'help': 'host name if not correctly detectable through gethostname', |
|
48 'group': 'main', 'level': 1, |
|
49 }), |
|
50 ('uid', |
|
51 {'type': 'string', |
|
52 'default': None, |
|
53 'help': 'unix user, if this option is set, use the specified user to start \ |
|
54 the repository rather than the user running the command', |
|
55 'group': 'main', 'level': WebConfiguration.mode == 'system' |
|
56 }), |
|
57 ('webserver-threadpool-size', |
|
58 {'type': 'int', |
|
59 'default': 4, |
|
60 'help': "size of twisted's reactor threadpool. It should probably be not too \ |
|
61 much greater than connection-poolsize", |
|
62 'group': 'web', 'level': 3, |
|
63 }), |
|
64 ) + WebConfigurationBase.options + ServerConfiguration.options |
|
65 ) |
|
66 |
|
67 cubicweb_appobject_path = ( |
|
68 WebConfigurationBase.cubicweb_appobject_path |
|
69 | ServerConfiguration.cubicweb_appobject_path |
|
70 ) |
|
71 cube_appobject_path = ( |
|
72 WebConfigurationBase.cube_appobject_path |
|
73 | ServerConfiguration.cube_appobject_path |
|
74 ) |
|
75 |
|
76 def server_file(self): |
|
77 return join(self.apphome, '%s-%s.py' % (self.appid, self.name)) |
|
78 |
|
79 |
|
80 CONFIGURATIONS.append(AllInOneConfiguration) |
|