Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
5efa6d28
Commit
5efa6d28
authored
9 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
Improve app factory encapsulation
parent
f5eec2f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/api.py
+19
-20
19 additions, 20 deletions
api/api.py
api/config.py
+1
-0
1 addition, 0 deletions
api/config.py
bin/api.wsgi
+1
-1
1 addition, 1 deletion
bin/api.wsgi
sample.config
+4
-3
4 additions, 3 deletions
sample.config
with
25 additions
and
24 deletions
api/api.py
+
19
−
20
View file @
5efa6d28
...
...
@@ -121,24 +121,23 @@ def dispatcher(router, request, response):
response
.
headers
[
'
Content-Type
'
]
=
'
application/json; charset=utf-8
'
application
=
webapp2
.
WSGIApplication
(
routes
)
application
.
router
.
set_dispatcher
(
dispatcher
)
# configure new relic
# don't use config.get_item() as we don't want to require the database at startup
if
config
.
__config
[
'
core
'
][
'
newrelic
'
]:
try
:
import
newrelic.agent
,
newrelic
.
api
.
exceptions
newrelic
.
agent
.
initialize
(
config
.
__config
[
'
core
'
][
'
newrelic
'
])
application
=
newrelic
.
agent
.
WSGIApplicationWrapper
(
application
)
log
.
info
(
'
New Relic detected and loaded. Monitoring enabled.
'
)
except
ImportError
:
log
.
critical
(
'
New Relic libraries not found.
'
)
sys
.
exit
(
1
)
except
newrelic
.
api
.
exceptions
.
ConfigurationError
:
log
.
critical
(
'
New Relic detected, but configuration invalid.
'
)
sys
.
exit
(
1
)
def
app_factory
(
_
,
**
__
):
def
app_factory
(
*
_
,
**
__
):
# don't use config.get_item() as we don't want to require the database at startup
application
=
webapp2
.
WSGIApplication
(
routes
,
debug
=
config
.
__config
[
'
core
'
][
'
debug
'
])
application
.
router
.
set_dispatcher
(
dispatcher
)
# configure new relic
if
config
.
__config
[
'
core
'
][
'
newrelic
'
]:
try
:
import
newrelic.agent
,
newrelic
.
api
.
exceptions
newrelic
.
agent
.
initialize
(
config
.
__config
[
'
core
'
][
'
newrelic
'
])
application
=
newrelic
.
agent
.
WSGIApplicationWrapper
(
application
)
log
.
info
(
'
New Relic detected and loaded. Monitoring enabled.
'
)
except
ImportError
:
log
.
critical
(
'
New Relic libraries not found.
'
)
sys
.
exit
(
1
)
except
newrelic
.
api
.
exceptions
.
ConfigurationError
:
log
.
critical
(
'
New Relic detected, but configuration invalid.
'
)
sys
.
exit
(
1
)
return
application
This diff is collapsed.
Click to expand it.
api/config.py
+
1
−
0
View file @
5efa6d28
...
...
@@ -22,6 +22,7 @@ logging.getLogger('paste.httpserver').setLevel(logging.WARNING) # silence Paste
DEFAULT_CONFIG
=
{
'
core
'
:
{
'
log_level
'
:
'
info
'
,
'
debug
'
:
False
,
'
insecure
'
:
False
,
'
newrelic
'
:
None
,
},
...
...
This diff is collapsed.
Click to expand it.
bin/api.wsgi
+
1
−
1
View file @
5efa6d28
...
...
@@ -2,7 +2,7 @@
from
api
import
api
application
=
api
.
app
lication
application
=
api
.
app
_factory
()
# FIXME: all code below should removed and ported into an app server independent framework
...
...
This diff is collapsed.
Click to expand it.
sample.config
+
4
−
3
View file @
5efa6d28
...
...
@@ -5,7 +5,8 @@
#SCITRAN_SYSTEM_RUNTIME="./runtime"
#SCITRAN_SYSTEM_SSL_PEM="*"
#SCITRAN_CORE_INSECURE=false
#SCITRAN_CORE_DEBUG=false # emit stack trace on error
#SCITRAN_CORE_INSECURE=false # accept user name as query param
#SCITRAN_CORE_LOG_LEVEL=debug
#SCITRAN_CORE_NEWRELIC=none
...
...
@@ -17,8 +18,8 @@
#SCITRAN_SITE_SSL_CERT=""
#SCITRAN_PERSISTENT_PATH="./persistent"
#SCITRAN_PERSISTENT_DATA_PATH="./persistent/data" # for fine-grain control
#SCITRAN_PERSISTENT_DB_PATH="./persistent/db" # for fine-grain control
#SCITRAN_PERSISTENT_DATA_PATH="./persistent/data"
# for fine-grain control
#SCITRAN_PERSISTENT_DB_PATH="./persistent/db"
# for fine-grain control
#SCITRAN_PERSISTENT_DB_PORT=9001
#SCITRAN_PERSISTENT_DB_URI="mongodb://localhost:$SCITRAN_PERSISTENT_DB_PORT/scitran"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment