##// END OF EJS Templates
Added force https option into config files
marcink -
r914:110a00c1 beta
parent child Browse files
Show More
@@ -1,215 +1,216 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # RhodeCode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by RhodeCode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 32 threadpool_max_requests = 6
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = false
36 36
37 37 use = egg:Paste#http
38 38 host = 0.0.0.0
39 39 port = 5000
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 44 static_files = true
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 48 cut_off_limit = 256000
49 force_https = false
49 50
50 51 ####################################
51 52 ### CELERY CONFIG ####
52 53 ####################################
53 54 use_celery = false
54 55 broker.host = localhost
55 56 broker.vhost = rabbitmqhost
56 57 broker.port = 5672
57 58 broker.user = rabbitmq
58 59 broker.password = qweqwe
59 60
60 61 celery.imports = rhodecode.lib.celerylib.tasks
61 62
62 63 celery.result.backend = amqp
63 64 celery.result.dburi = amqp://
64 65 celery.result.serialier = json
65 66
66 67 #celery.send.task.error.emails = true
67 68 #celery.amqp.task.result.expires = 18000
68 69
69 70 celeryd.concurrency = 2
70 71 #celeryd.log.file = celeryd.log
71 72 celeryd.log.level = debug
72 73 celeryd.max.tasks.per.child = 3
73 74
74 75 #tasks will never be sent to the queue, but executed locally instead.
75 76 celery.always.eager = false
76 77
77 78 ####################################
78 79 ### BEAKER CACHE ####
79 80 ####################################
80 81 beaker.cache.data_dir=/%(here)s/data/cache/data
81 82 beaker.cache.lock_dir=/%(here)s/data/cache/lock
82 83 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
83 84
84 85 beaker.cache.super_short_term.type=memory
85 86 beaker.cache.super_short_term.expire=10
86 87
87 88 beaker.cache.short_term.type=memory
88 89 beaker.cache.short_term.expire=60
89 90
90 91 beaker.cache.long_term.type=memory
91 92 beaker.cache.long_term.expire=36000
92 93
93 94 beaker.cache.sql_cache_short.type=memory
94 95 beaker.cache.sql_cache_short.expire=10
95 96
96 97 beaker.cache.sql_cache_med.type=memory
97 98 beaker.cache.sql_cache_med.expire=360
98 99
99 100 beaker.cache.sql_cache_long.type=file
100 101 beaker.cache.sql_cache_long.expire=3600
101 102
102 103 ####################################
103 104 ### BEAKER SESSION ####
104 105 ####################################
105 106 ## Type of storage used for the session, current types are
106 107 ## dbm, file, memcached, database, and memory.
107 108 ## The storage uses the Container API
108 109 ##that is also used by the cache system.
109 110 beaker.session.type = file
110 111
111 112 beaker.session.key = rhodecode
112 113 beaker.session.secret = g654dcno0-9873jhgfreyu
113 114 beaker.session.timeout = 36000
114 115
115 116 ##auto save the session to not to use .save()
116 117 beaker.session.auto = False
117 118
118 119 ##true exire at browser close
119 120 #beaker.session.cookie_expires = 3600
120 121
121 122
122 123 ################################################################################
123 124 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
124 125 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
125 126 ## execute malicious code after an exception is raised. ##
126 127 ################################################################################
127 128 #set debug = false
128 129
129 130 ##################################
130 131 ### LOGVIEW CONFIG ###
131 132 ##################################
132 133 logview.sqlalchemy = #faa
133 134 logview.pylons.templating = #bfb
134 135 logview.pylons.util = #eee
135 136
136 137 #########################################################
137 138 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
138 139 #########################################################
139 140 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
140 141 #sqlalchemy.db1.echo = False
141 142 #sqlalchemy.db1.pool_recycle = 3600
142 143 sqlalchemy.convert_unicode = true
143 144
144 145 ################################
145 146 ### LOGGING CONFIGURATION ####
146 147 ################################
147 148 [loggers]
148 149 keys = root, routes, rhodecode, sqlalchemy,beaker,templates
149 150
150 151 [handlers]
151 152 keys = console
152 153
153 154 [formatters]
154 155 keys = generic,color_formatter
155 156
156 157 #############
157 158 ## LOGGERS ##
158 159 #############
159 160 [logger_root]
160 161 level = NOTSET
161 162 handlers = console
162 163
163 164 [logger_routes]
164 165 level = DEBUG
165 166 handlers = console
166 167 qualname = routes.middleware
167 168 # "level = DEBUG" logs the route matched and routing variables.
168 169 propagate = 0
169 170
170 171 [logger_beaker]
171 172 level = ERROR
172 173 handlers = console
173 174 qualname = beaker.container
174 175 propagate = 0
175 176
176 177 [logger_templates]
177 178 level = INFO
178 179 handlers = console
179 180 qualname = pylons.templating
180 181 propagate = 0
181 182
182 183 [logger_rhodecode]
183 184 level = DEBUG
184 185 handlers = console
185 186 qualname = rhodecode
186 187 propagate = 0
187 188
188 189 [logger_sqlalchemy]
189 190 level = ERROR
190 191 handlers = console
191 192 qualname = sqlalchemy.engine
192 193 propagate = 0
193 194
194 195 ##############
195 196 ## HANDLERS ##
196 197 ##############
197 198
198 199 [handler_console]
199 200 class = StreamHandler
200 201 args = (sys.stderr,)
201 202 level = NOTSET
202 203 formatter = color_formatter
203 204
204 205 ################
205 206 ## FORMATTERS ##
206 207 ################
207 208
208 209 [formatter_generic]
209 210 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
210 211 datefmt = %Y-%m-%d %H:%M:%S
211 212
212 213 [formatter_color_formatter]
213 214 class=rhodecode.lib.colored_formatter.ColorFormatter
214 215 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
215 216 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,204 +1,205 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # rhodecode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by rhodecode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 32 threadpool_max_requests = 2
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = true
36 36
37 37 use = egg:Paste#http
38 38 host = 127.0.0.1
39 39 port = 8001
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 44 static_files = false
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 48 cut_off_limit = 256000
49 force_https = false
49 50
50 51 ####################################
51 52 ### CELERY CONFIG ####
52 53 ####################################
53 54 use_celery = false
54 55 broker.host = localhost
55 56 broker.vhost = rabbitmqhost
56 57 broker.port = 5672
57 58 broker.user = rabbitmq
58 59 broker.password = qweqwe
59 60
60 61 celery.imports = rhodecode.lib.celerylib.tasks
61 62
62 63 celery.result.backend = amqp
63 64 celery.result.dburi = amqp://
64 65 celery.result.serialier = json
65 66
66 67 #celery.send.task.error.emails = true
67 68 #celery.amqp.task.result.expires = 18000
68 69
69 70 celeryd.concurrency = 2
70 71 #celeryd.log.file = celeryd.log
71 72 celeryd.log.level = debug
72 73 celeryd.max.tasks.per.child = 3
73 74
74 75 #tasks will never be sent to the queue, but executed locally instead.
75 76 celery.always.eager = false
76 77
77 78 ####################################
78 79 ### BEAKER CACHE ####
79 80 ####################################
80 81 beaker.cache.data_dir=/%(here)s/data/cache/data
81 82 beaker.cache.lock_dir=/%(here)s/data/cache/lock
82 83 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
83 84
84 85 beaker.cache.super_short_term.type=memory
85 86 beaker.cache.super_short_term.expire=10
86 87
87 88 beaker.cache.short_term.type=memory
88 89 beaker.cache.short_term.expire=60
89 90
90 91 beaker.cache.long_term.type=memory
91 92 beaker.cache.long_term.expire=36000
92 93
93 94
94 95 beaker.cache.sql_cache_short.type=memory
95 96 beaker.cache.sql_cache_short.expire=5
96 97
97 98 beaker.cache.sql_cache_med.type=memory
98 99 beaker.cache.sql_cache_med.expire=360
99 100
100 101 beaker.cache.sql_cache_long.type=file
101 102 beaker.cache.sql_cache_long.expire=3600
102 103
103 104 ####################################
104 105 ### BEAKER SESSION ####
105 106 ####################################
106 107 ## Type of storage used for the session, current types are
107 108 ## dbm, file, memcached, database, and memory.
108 109 ## The storage uses the Container API
109 110 ##that is also used by the cache system.
110 111 beaker.session.type = file
111 112
112 113 beaker.session.key = rhodecode
113 114 beaker.session.secret = g654dcno0-9873jhgfreyu
114 115 beaker.session.timeout = 36000
115 116
116 117 ##auto save the session to not to use .save()
117 118 beaker.session.auto = False
118 119
119 120 ##true exire at browser close
120 121 #beaker.session.cookie_expires = 3600
121 122
122 123
123 124 ################################################################################
124 125 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
125 126 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
126 127 ## execute malicious code after an exception is raised. ##
127 128 ################################################################################
128 129 set debug = false
129 130
130 131 ##################################
131 132 ### LOGVIEW CONFIG ###
132 133 ##################################
133 134 logview.sqlalchemy = #faa
134 135 logview.pylons.templating = #bfb
135 136 logview.pylons.util = #eee
136 137
137 138 #########################################################
138 139 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
139 140 #########################################################
140 141 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
141 142 #sqlalchemy.db1.echo = False
142 143 #sqlalchemy.db1.pool_recycle = 3600
143 144 sqlalchemy.convert_unicode = true
144 145
145 146 ################################
146 147 ### LOGGING CONFIGURATION ####
147 148 ################################
148 149 [loggers]
149 150 keys = root, routes, rhodecode, sqlalchemy
150 151
151 152 [handlers]
152 153 keys = console
153 154
154 155 [formatters]
155 156 keys = generic,color_formatter
156 157
157 158 #############
158 159 ## LOGGERS ##
159 160 #############
160 161 [logger_root]
161 162 level = INFO
162 163 handlers = console
163 164
164 165 [logger_routes]
165 166 level = INFO
166 167 handlers = console
167 168 qualname = routes.middleware
168 169 # "level = DEBUG" logs the route matched and routing variables.
169 170 propagate = 0
170 171
171 172 [logger_rhodecode]
172 173 level = DEBUG
173 174 handlers = console
174 175 qualname = rhodecode
175 176 propagate = 0
176 177
177 178 [logger_sqlalchemy]
178 179 level = ERROR
179 180 handlers = console
180 181 qualname = sqlalchemy.engine
181 182 propagate = 0
182 183
183 184 ##############
184 185 ## HANDLERS ##
185 186 ##############
186 187
187 188 [handler_console]
188 189 class = StreamHandler
189 190 args = (sys.stderr,)
190 191 level = NOTSET
191 192 formatter = color_formatter
192 193
193 194 ################
194 195 ## FORMATTERS ##
195 196 ################
196 197
197 198 [formatter_generic]
198 199 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
199 200 datefmt = %Y-%m-%d %H:%M:%S
200 201
201 202 [formatter_color_formatter]
202 203 class=rhodecode.lib.colored_formatter.ColorFormatter
203 204 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
204 205 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,204 +1,205 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # RhodeCode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by RhodeCode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 32 threadpool_max_requests = 10
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = true
36 36
37 37 use = egg:Paste#http
38 38 host = 127.0.0.1
39 39 port = 5000
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 44 static_files = true
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 48 app_instance_uuid = ${app_instance_uuid}
49 49 cut_off_limit = 256000
50 force_https = false
50 51
51 52 ####################################
52 53 ### CELERY CONFIG ####
53 54 ####################################
54 55 use_celery = false
55 56 broker.host = localhost
56 57 broker.vhost = rabbitmqhost
57 58 broker.port = 5672
58 59 broker.user = rabbitmq
59 60 broker.password = qweqwe
60 61
61 62 celery.imports = rhodecode.lib.celerylib.tasks
62 63
63 64 celery.result.backend = amqp
64 65 celery.result.dburi = amqp://
65 66 celery.result.serialier = json
66 67
67 68 #celery.send.task.error.emails = true
68 69 #celery.amqp.task.result.expires = 18000
69 70
70 71 celeryd.concurrency = 2
71 72 #celeryd.log.file = celeryd.log
72 73 celeryd.log.level = debug
73 74 celeryd.max.tasks.per.child = 3
74 75
75 76 #tasks will never be sent to the queue, but executed locally instead.
76 77 celery.always.eager = false
77 78
78 79 ####################################
79 80 ### BEAKER CACHE ####
80 81 ####################################
81 82 beaker.cache.data_dir=/%(here)s/data/cache/data
82 83 beaker.cache.lock_dir=/%(here)s/data/cache/lock
83 84 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
84 85
85 86 beaker.cache.super_short_term.type=memory
86 87 beaker.cache.super_short_term.expire=10
87 88
88 89 beaker.cache.short_term.type=memory
89 90 beaker.cache.short_term.expire=60
90 91
91 92 beaker.cache.long_term.type=memory
92 93 beaker.cache.long_term.expire=36000
93 94
94 95 beaker.cache.sql_cache_short.type=memory
95 96 beaker.cache.sql_cache_short.expire=10
96 97
97 98 beaker.cache.sql_cache_med.type=memory
98 99 beaker.cache.sql_cache_med.expire=360
99 100
100 101 beaker.cache.sql_cache_long.type=file
101 102 beaker.cache.sql_cache_long.expire=3600
102 103
103 104 ####################################
104 105 ### BEAKER SESSION ####
105 106 ####################################
106 107 ## Type of storage used for the session, current types are
107 108 ## dbm, file, memcached, database, and memory.
108 109 ## The storage uses the Container API
109 110 ##that is also used by the cache system.
110 111 beaker.session.type = file
111 112
112 113 beaker.session.key = rhodecode
113 114 beaker.session.secret = ${app_instance_secret}
114 115 beaker.session.timeout = 36000
115 116
116 117 ##auto save the session to not to use .save()
117 118 beaker.session.auto = False
118 119
119 120 ##true exire at browser close
120 121 #beaker.session.cookie_expires = 3600
121 122
122 123
123 124 ################################################################################
124 125 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
125 126 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
126 127 ## execute malicious code after an exception is raised. ##
127 128 ################################################################################
128 129 set debug = false
129 130
130 131 ##################################
131 132 ### LOGVIEW CONFIG ###
132 133 ##################################
133 134 logview.sqlalchemy = #faa
134 135 logview.pylons.templating = #bfb
135 136 logview.pylons.util = #eee
136 137
137 138 #########################################################
138 139 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
139 140 #########################################################
140 141 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
141 142 #sqlalchemy.db1.echo = False
142 143 #sqlalchemy.db1.pool_recycle = 3600
143 144 sqlalchemy.convert_unicode = true
144 145
145 146 ################################
146 147 ### LOGGING CONFIGURATION ####
147 148 ################################
148 149 [loggers]
149 150 keys = root, routes, rhodecode, sqlalchemy
150 151
151 152 [handlers]
152 153 keys = console
153 154
154 155 [formatters]
155 156 keys = generic,color_formatter
156 157
157 158 #############
158 159 ## LOGGERS ##
159 160 #############
160 161 [logger_root]
161 162 level = INFO
162 163 handlers = console
163 164
164 165 [logger_routes]
165 166 level = INFO
166 167 handlers = console
167 168 qualname = routes.middleware
168 169 # "level = DEBUG" logs the route matched and routing variables.
169 170 propagate = 0
170 171
171 172 [logger_rhodecode]
172 173 level = DEBUG
173 174 handlers = console
174 175 qualname = rhodecode
175 176 propagate = 0
176 177
177 178 [logger_sqlalchemy]
178 179 level = ERROR
179 180 handlers = console
180 181 qualname = sqlalchemy.engine
181 182 propagate = 0
182 183
183 184 ##############
184 185 ## HANDLERS ##
185 186 ##############
186 187
187 188 [handler_console]
188 189 class = StreamHandler
189 190 args = (sys.stderr,)
190 191 level = NOTSET
191 192 formatter = color_formatter
192 193
193 194 ################
194 195 ## FORMATTERS ##
195 196 ################
196 197
197 198 [formatter_generic]
198 199 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
199 200 datefmt = %Y-%m-%d %H:%M:%S
200 201
201 202 [formatter_color_formatter]
202 203 class=rhodecode.lib.colored_formatter.ColorFormatter
203 204 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
204 205 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,76 +1,76 b''
1 1 """Pylons middleware initialization"""
2 2 from beaker.middleware import SessionMiddleware
3 3 from paste.cascade import Cascade
4 4 from paste.registry import RegistryManager
5 5 from paste.urlparser import StaticURLParser
6 6 from paste.deploy.converters import asbool
7 7 from pylons.middleware import ErrorHandler, StatusCodeRedirect
8 8 from pylons.wsgiapp import PylonsApp
9 9 from routes.middleware import RoutesMiddleware
10 10 from rhodecode.lib.middleware.simplehg import SimpleHg
11 11 from rhodecode.lib.middleware.simplegit import SimpleGit
12 12 from rhodecode.lib.middleware.https_fixup import HttpsFixup
13 13 from rhodecode.config.environment import load_environment
14 14 from paste.gzipper import make_gzip_middleware
15 15
16 16 def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
17 17 """Create a Pylons WSGI application and return it
18 18
19 19 ``global_conf``
20 20 The inherited configuration for this application. Normally from
21 21 the [DEFAULT] section of the Paste ini file.
22 22
23 23 ``full_stack``
24 24 Whether or not this application provides a full WSGI stack (by
25 25 default, meaning it handles its own exceptions and errors).
26 26 Disable full_stack when this application is "managed" by
27 27 another WSGI middleware.
28 28
29 29 ``app_conf``
30 30 The application's local configuration. Normally specified in
31 31 the [app:<name>] section of the Paste ini file (where <name>
32 32 defaults to main).
33 33
34 34 """
35 35 # Configure the Pylons environment
36 36 config = load_environment(global_conf, app_conf)
37 37
38 38 # The Pylons WSGI app
39 39 app = PylonsApp(config=config)
40 40
41 41 # Routing/Session/Cache Middleware
42 42 app = RoutesMiddleware(app, config['routes.map'])
43 43 app = SessionMiddleware(app, config)
44 44
45 45 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
46 46
47 47 app = SimpleHg(app, config)
48 48 app = SimpleGit(app, config)
49 49
50 50 if asbool(full_stack):
51 51 # Handle Python exceptions
52 52 app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
53 53
54 54 # Display error documents for 401, 403, 404 status codes (and
55 55 # 500 when debug is disabled)
56 56 if asbool(config['debug']):
57 57 app = StatusCodeRedirect(app)
58 58 else:
59 59 app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
60 60
61 61 #enable https redirets based on HTTP_X_URL_SCHEME set by proxy
62 app = HttpsFixup(app)
62 app = HttpsFixup(app, config)
63 63
64 64 # Establish the Registry for this application
65 65 app = RegistryManager(app)
66 66
67 67 if asbool(static_files):
68 68 # Serve static files
69 69 static_app = StaticURLParser(config['pylons.paths']['static_files'])
70 70 app = Cascade([static_app, app])
71 71 app = make_gzip_middleware(app, global_conf, compress_level=1)
72 72
73 73 app.config = config
74 74
75 75 return app
76 76
@@ -0,0 +1,29 b''
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.lib.__init__
4 ~~~~~~~~~~~~~~~~~~~~~~~
5
6 Some simple helper functions
7
8 :created_on: Jan 5, 2011
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; version 2
16 # of the License or (at your opinion) any later version of the license.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 # MA 02110-1301, USA.
27
28 def str2bool(v):
29 return v.lower() in ["yes", "true", "t", "1"] if v else None
@@ -1,106 +1,104 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 rhodecode.lib.celerylib.__init__
4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 6 celery libs for RhodeCode
7 7
8 8 :created_on: Nov 27, 2010
9 9 :author: marcink
10 10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
11 11 :license: GPLv3, see COPYING for more details.
12 12 """
13 13 # This program is free software; you can redistribute it and/or
14 14 # modify it under the terms of the GNU General Public License
15 15 # as published by the Free Software Foundation; version 2
16 16 # of the License or (at your opinion) any later version of the license.
17 17 #
18 18 # This program is distributed in the hope that it will be useful,
19 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 21 # GNU General Public License for more details.
22 22 #
23 23 # You should have received a copy of the GNU General Public License
24 24 # along with this program; if not, write to the Free Software
25 25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 26 # MA 02110-1301, USA.
27 27
28 28 import os
29 29 import sys
30 30 import socket
31 31 import traceback
32 32 import logging
33 33
34 34 from hashlib import md5
35 35 from decorator import decorator
36 36 from vcs.utils.lazy import LazyProperty
37 37
38 from rhodecode.lib import str2bool
38 39 from rhodecode.lib.pidlock import DaemonLock, LockHeld
39 40
40 41 from pylons import config
41 42
42 43 log = logging.getLogger(__name__)
43 44
44 def str2bool(v):
45 return v.lower() in ["yes", "true", "t", "1"] if v else None
46
47 45 try:
48 46 CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
49 47 except KeyError:
50 48 CELERY_ON = False
51 49
52 50 class ResultWrapper(object):
53 51 def __init__(self, task):
54 52 self.task = task
55 53
56 54 @LazyProperty
57 55 def result(self):
58 56 return self.task
59 57
60 58 def run_task(task, *args, **kwargs):
61 59 if CELERY_ON:
62 60 try:
63 61 t = task.delay(*args, **kwargs)
64 62 log.info('running task %s:%s', t.task_id, task)
65 63 return t
66 64 except socket.error, e:
67 65 if e.errno == 111:
68 66 log.debug('Unable to connect to celeryd. Sync execution')
69 67 else:
70 68 log.error(traceback.format_exc())
71 69 except KeyError, e:
72 70 log.debug('Unable to connect to celeryd. Sync execution')
73 71 except Exception, e:
74 72 log.error(traceback.format_exc())
75 73
76 74 log.debug('executing task %s in sync mode', task)
77 75 return ResultWrapper(task(*args, **kwargs))
78 76
79 77
80 78 def locked_task(func):
81 79 def __wrapper(func, *fargs, **fkwargs):
82 80 params = list(fargs)
83 81 params.extend(['%s-%s' % ar for ar in fkwargs.items()])
84 82
85 83 lockkey = 'task_%s' % \
86 84 md5(str(func.__name__) + '-' + \
87 85 '-'.join(map(str, params))).hexdigest()
88 86 log.info('running task with lockkey %s', lockkey)
89 87 try:
90 88 l = DaemonLock(lockkey)
91 89 ret = func(*fargs, **fkwargs)
92 90 l.release()
93 91 return ret
94 92 except LockHeld:
95 93 log.info('LockHeld')
96 94 return 'Task with key %s already running' % lockkey
97 95
98 96 return decorator(__wrapper, func)
99 97
100 98
101 99
102 100
103 101
104 102
105 103
106 104
@@ -1,48 +1,54 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 rhodecode.lib.middleware.https_fixup
4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 6 middleware to handle https correctly
7 7
8 8 :created_on: May 23, 2010
9 9 :author: marcink
10 10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
11 11 :license: GPLv3, see COPYING for more details.
12 12 """
13 13 # This program is free software; you can redistribute it and/or
14 14 # modify it under the terms of the GNU General Public License
15 15 # as published by the Free Software Foundation; version 2
16 16 # of the License or (at your opinion) any later version of the license.
17 17 #
18 18 # This program is distributed in the hope that it will be useful,
19 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 21 # GNU General Public License for more details.
22 22 #
23 23 # You should have received a copy of the GNU General Public License
24 24 # along with this program; if not, write to the Free Software
25 25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 26 # MA 02110-1301, USA.
27 27
28 from rhodecode.lib import str2bool
29
28 30 class HttpsFixup(object):
29 def __init__(self, app):
31 def __init__(self, app, config):
30 32 self.application = app
33 self.config = config
31 34
32 35 def __call__(self, environ, start_response):
33 36 self.__fixup(environ)
34 37 return self.application(environ, start_response)
35 38
36 39
37 40 def __fixup(self, environ):
38 41 """Function to fixup the environ as needed. In order to use this
39 42 middleware you should set this header inside your
40 43 proxy ie. nginx, apache etc.
41 44 """
42 45 proto = environ.get('HTTP_X_URL_SCHEME')
43 46
47 if str2bool(self.config.get('force_https')):
48 proto = 'https'
49
44 50 if proto == 'https':
45 51 environ['wsgi.url_scheme'] = proto
46 52 else:
47 53 environ['wsgi.url_scheme'] = 'http'
48 54 return None
General Comments 0
You need to be logged in to leave comments. Login now