Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
97201847
Commit
97201847
authored
7 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Move web service entrypoint to separate script in bin folder
parent
1dc8ca2d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/geomag_webservice.py
+36
-0
36 additions, 0 deletions
bin/geomag_webservice.py
geomagio/WebService.py
+0
-8
0 additions, 8 deletions
geomagio/WebService.py
with
36 additions
and
8 deletions
bin/geomag_webservice.py
0 → 100755
+
36
−
0
View file @
97201847
#! /usr/bin/env python
from
__future__
import
absolute_import
,
print_function
from
builtins
import
str
as
unicode
import
os
import
sys
from
wsgiref.simple_server
import
make_server
# ensure geomag is on the path before importing
try
:
import
geomagio
# noqa (tells linter to ignore this line.)
except
:
path
=
os
.
path
script_dir
=
path
.
dirname
(
path
.
abspath
(
__file__
))
sys
.
path
.
append
(
path
.
normpath
(
path
.
join
(
script_dir
,
'
..
'
)))
import
geomagio
if
__name__
==
'
__main__
'
:
# read configuration from environment
edge_host
=
os
.
getenv
(
'
EDGE_HOST
'
,
'
cwbpub.cr.usgs.gov
'
)
edge_port
=
int
(
os
.
getenv
(
'
EDGE_PORT
'
,
'
2060
'
))
factory_type
=
os
.
getenv
(
'
GEOMAG_FACTORY_TYPE
'
,
'
edge
'
)
webservice_host
=
os
.
getenv
(
'
GEOMAG_WEBSERVICE_HOST
'
,
''
)
webservice_port
=
int
(
os
.
getenv
(
'
GEOMAG_WEBSERVICE_PORT
'
,
'
7981
'
))
# configure factory
if
factory_type
==
'
edge
'
:
factory
=
geomagio
.
edge
.
EdgeFactory
(
host
=
edge_host
,
port
=
edge_port
)
else
:
raise
"
Unknown factory type
'
%s
'"
%
factory_type
print
(
"
Starting webservice on %s:%d
"
%
(
webservice_host
,
webservice_port
))
app
=
geomagio
.
WebService
(
factory
)
httpd
=
make_server
(
webservice_host
,
webservice_port
,
app
)
httpd
.
serve_forever
()
This diff is collapsed.
Click to expand it.
geomagio/WebService.py
+
0
−
8
View file @
97201847
...
@@ -343,11 +343,3 @@ class WebServiceQuery(object):
...
@@ -343,11 +343,3 @@ class WebServiceQuery(object):
class
WebServiceException
(
Exception
):
class
WebServiceException
(
Exception
):
"""
Base class for exceptions thrown by web services.
"""
"""
Base class for exceptions thrown by web services.
"""
pass
pass
if
__name__
==
'
__main__
'
:
from
wsgiref.simple_server
import
make_server
app
=
WebService
(
EdgeFactory
())
httpd
=
make_server
(
''
,
7981
,
app
)
httpd
.
serve_forever
()
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