author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 08 Sep 2015 16:24:57 +0200 | |
changeset 10656 | 0b1d03f07b87 |
parent 10301 | 729f36a1bcfa |
permissions | -rw-r--r-- |
10235
684215aca046
Remove remote repository-access-through-pyro support
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9252
diff
changeset
|
1 |
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""twisted server configurations: |
19 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
20 |
* the "all-in-one" configuration to get a web instance running in a twisted |
0 | 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 |
__docformat__ = "restructuredtext en" |
|
25 |
||
26 |
from os.path import join |
|
27 |
||
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8828
diff
changeset
|
28 |
from logilab.common.configuration import Method, merge_options |
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
29 |
|
6844
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6829
diff
changeset
|
30 |
from cubicweb.cwconfig import CONFIGURATIONS |
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8828
diff
changeset
|
31 |
from cubicweb.web.webconfig import WebConfiguration |
0 | 32 |
|
6844
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6829
diff
changeset
|
33 |
|
9252
01bca75ee8bd
[devtools,etwist] rename TwistedConfiguration to WebConfigurationBase (follows #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
34 |
class WebConfigurationBase(WebConfiguration): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
35 |
"""web instance (in a twisted web server) client of a RQL server""" |
0 | 36 |
|
37 |
options = merge_options(( |
|
38 |
# ctl configuration |
|
5554
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
39 |
('port', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
40 |
{'type' : 'int', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
41 |
'default': None, |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
42 |
'help': 'http server port number (default to 8080)', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
43 |
'group': 'web', 'level': 0, |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
44 |
}), |
6817
1959d97ebf2e
[etwist] add an 'interface' config option (passed to reactor.listenTCP)
david.douard@logilab.fr
parents:
6012
diff
changeset
|
45 |
('interface', |
1959d97ebf2e
[etwist] add an 'interface' config option (passed to reactor.listenTCP)
david.douard@logilab.fr
parents:
6012
diff
changeset
|
46 |
{'type' : 'string', |
1959d97ebf2e
[etwist] add an 'interface' config option (passed to reactor.listenTCP)
david.douard@logilab.fr
parents:
6012
diff
changeset
|
47 |
'default': "", |
1959d97ebf2e
[etwist] add an 'interface' config option (passed to reactor.listenTCP)
david.douard@logilab.fr
parents:
6012
diff
changeset
|
48 |
'help': 'http server address on which to listen (default to everywhere)', |
6829
43d70b3fdcb5
[c-c create] don't ask for web server interface at level 0
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6817
diff
changeset
|
49 |
'group': 'web', 'level': 1, |
6817
1959d97ebf2e
[etwist] add an 'interface' config option (passed to reactor.listenTCP)
david.douard@logilab.fr
parents:
6012
diff
changeset
|
50 |
}), |
5554
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
51 |
('max-post-length', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
52 |
{'type' : 'bytes', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
53 |
'default': '100MB', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
54 |
'help': 'maximum length of HTTP request. Default to 100 MB.', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
55 |
'group': 'web', 'level': 1, |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
56 |
}), |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
57 |
('profile', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
58 |
{'type' : 'string', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
59 |
'default': None, |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
60 |
'help': 'profile code and use the specified file to store stats if this option is set', |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
61 |
'group': 'web', 'level': 3, |
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
62 |
}), |
0 | 63 |
('host', |
64 |
{'type' : 'string', |
|
65 |
'default': None, |
|
66 |
'help': 'host name if not correctly detectable through gethostname', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
67 |
'group': 'main', 'level': 1, |
0 | 68 |
}), |
69 |
('pid-file', |
|
70 |
{'type' : 'string', |
|
71 |
'default': Method('default_pid_file'), |
|
72 |
'help': 'repository\'s pid file', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
73 |
'group': 'main', 'level': 2, |
0 | 74 |
}), |
75 |
('uid', |
|
76 |
{'type' : 'string', |
|
77 |
'default': None, |
|
78 |
'help': 'if this option is set, use the specified user to start \ |
|
79 |
the repository rather than the user running the command', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
80 |
'group': 'main', 'level': WebConfiguration.mode == 'system' |
0 | 81 |
}), |
7644
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
82 |
('webserver-threadpool-size', |
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
83 |
{'type': 'int', |
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
84 |
'default': 4, |
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
85 |
'help': "size of twisted's reactor threadpool. It should probably be not too \ |
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
86 |
much greater than connection-poolsize", |
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
87 |
'group': 'web', 'level': 3, |
7a0914469618
[twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6844
diff
changeset
|
88 |
}), |
0 | 89 |
) + WebConfiguration.options) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
90 |
|
0 | 91 |
def server_file(self): |
92 |
return join(self.apphome, '%s-%s.py' % (self.appid, self.name)) |
|
93 |
||
94 |
def default_base_url(self): |
|
8828
1437c47925c3
default base-url now uses fdqn instead of hostname only (closes #2542815)
Florent Cayre <florent.cayre@logilab.fr>
parents:
8669
diff
changeset
|
95 |
from socket import getfqdn |
10224
996cf2c0ec99
[config] Lowercase the FQDN we get from the OS (closes #5040345)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9252
diff
changeset
|
96 |
return 'http://%s:%s/' % (self['host'] or getfqdn().lower(), self['port'] or 8080) |
0 | 97 |
|
6844
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6829
diff
changeset
|
98 |
|
0 | 99 |
try: |
100 |
from cubicweb.server.serverconfig import ServerConfiguration |
|
101 |
||
9252
01bca75ee8bd
[devtools,etwist] rename TwistedConfiguration to WebConfigurationBase (follows #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
102 |
class AllInOneConfiguration(WebConfigurationBase, ServerConfiguration): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
103 |
"""repository and web instance in the same twisted process""" |
0 | 104 |
name = 'all-in-one' |
9252
01bca75ee8bd
[devtools,etwist] rename TwistedConfiguration to WebConfigurationBase (follows #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
105 |
options = merge_options(WebConfigurationBase.options |
0 | 106 |
+ ServerConfiguration.options) |
107 |
||
9252
01bca75ee8bd
[devtools,etwist] rename TwistedConfiguration to WebConfigurationBase (follows #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
108 |
cubicweb_appobject_path = WebConfigurationBase.cubicweb_appobject_path | ServerConfiguration.cubicweb_appobject_path |
01bca75ee8bd
[devtools,etwist] rename TwistedConfiguration to WebConfigurationBase (follows #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
109 |
cube_appobject_path = WebConfigurationBase.cube_appobject_path | ServerConfiguration.cube_appobject_path |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
110 |
|
6844
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6829
diff
changeset
|
111 |
|
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6829
diff
changeset
|
112 |
CONFIGURATIONS.append(AllInOneConfiguration) |
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6829
diff
changeset
|
113 |
|
0 | 114 |
except ImportError: |
115 |
pass |