##// END OF EJS Templates
ssh: allow customizing the base_url for running application....
marcink -
r2188:397144e9 default
parent child Browse files
Show More
@@ -0,0 +1,43 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 import ConfigParser
22 from pyramid.paster import bootstrap as pyramid_bootstrap
23 from pyramid.request import Request
24
25
26 def get_config(ini_path):
27 parser = ConfigParser.ConfigParser()
28 parser.read(ini_path)
29 return parser
30
31
32 def bootstrap(config_uri, request=None, options=None):
33
34 config = get_config(config_uri)
35 base_url = 'http://rhodecode.local'
36 try:
37 base_url = config.get('app:main', 'app.base_url')
38 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
39 pass
40
41 request = request or Request.blank('/', base_url=base_url)
42
43 return pyramid_bootstrap(config_uri, request=request, options=options)
@@ -162,6 +162,11 b' startup.import_repos = false'
162 ## the repository.
162 ## the repository.
163 #archive_cache_dir = /tmp/tarballcache
163 #archive_cache_dir = /tmp/tarballcache
164
164
165 ## URL at which the application is running. This is used for bootstraping
166 ## requests in context when no web request is available. Used in ishell, or
167 ## SSH calls. Set this for events to receive proper url for SSH calls.
168 app.base_url = http://rhodecode.local
169
165 ## change this to unique ID for security
170 ## change this to unique ID for security
166 app_instance_uuid = rc-production
171 app_instance_uuid = rc-production
167
172
@@ -137,6 +137,11 b' startup.import_repos = false'
137 ## the repository.
137 ## the repository.
138 #archive_cache_dir = /tmp/tarballcache
138 #archive_cache_dir = /tmp/tarballcache
139
139
140 ## URL at which the application is running. This is used for bootstraping
141 ## requests in context when no web request is available. Used in ishell, or
142 ## SSH calls. Set this for events to receive proper url for SSH calls.
143 app.base_url = http://rhodecode.local
144
140 ## change this to unique ID for security
145 ## change this to unique ID for security
141 app_instance_uuid = rc-production
146 app_instance_uuid = rc-production
142
147
@@ -24,9 +24,9 b' import logging'
24
24
25 import click
25 import click
26
26
27 from pyramid.paster import bootstrap, setup_logging
27 from pyramid.paster import setup_logging
28 from pyramid.request import Request
29
28
29 from rhodecode.lib.pyramid_utils import bootstrap
30 from .backends import SshWrapper
30 from .backends import SshWrapper
31
31
32 log = logging.getLogger(__name__)
32 log = logging.getLogger(__name__)
@@ -68,9 +68,7 b' def main(ini_path, mode, user, user_id, '
68 'of this script.')
68 'of this script.')
69 connection_info = os.environ.get('SSH_CONNECTION', '')
69 connection_info = os.environ.get('SSH_CONNECTION', '')
70
70
71 # TODO(marcink): configure the running host...
71 with bootstrap(ini_path) as env:
72 request = Request.blank('/', base_url='http://localhost:8080')
73 with bootstrap(ini_path, request=request) as env:
74 try:
72 try:
75 ssh_wrapper = SshWrapper(
73 ssh_wrapper = SshWrapper(
76 command, connection_info, mode,
74 command, connection_info, mode,
@@ -207,6 +207,11 b' startup.import_repos = true'
207 ## the repository.
207 ## the repository.
208 #archive_cache_dir = /tmp/tarballcache
208 #archive_cache_dir = /tmp/tarballcache
209
209
210 ## URL at which the application is running. This is used for bootstraping
211 ## requests in context when no web request is available. Used in ishell, or
212 ## SSH calls. Set this for events to receive proper url for SSH calls.
213 app.base_url = http://rhodecode.local
214
210 ## change this to unique ID for security
215 ## change this to unique ID for security
211 app_instance_uuid = rc-production
216 app_instance_uuid = rc-production
212
217
General Comments 0
You need to be logged in to leave comments. Login now