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
a3c2d85f
Commit
a3c2d85f
authored
10 years ago
by
Kevin S. Hahn
Browse files
Options
Downloads
Patches
Plain Diff
rename internimsclient to centralclient
parent
acd5ba3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api.py
+2
-2
2 additions, 2 deletions
api.py
api.wsgi
+5
-5
5 additions, 5 deletions
api.wsgi
centralclient.py
+6
-6
6 additions, 6 deletions
centralclient.py
with
13 additions
and
13 deletions
api.py
+
2
−
2
View file @
a3c2d85f
...
...
@@ -139,9 +139,9 @@ if __name__ == '__main__':
app
.
config
[
'
demo
'
]
=
args
.
demo
if
not
app
.
config
[
'
ssl_cert
'
]:
log
.
warning
(
'
SSL certificate not specified,
interNIMS
functionality disabled
'
)
log
.
warning
(
'
SSL certificate not specified,
scitran central
functionality disabled
'
)
elif
not
app
.
config
[
'
site_id
'
]:
log
.
warning
(
'
site_id not configured,
interNIMS
functionality disabled
'
)
log
.
warning
(
'
site_id not configured,
scitran central
functionality disabled
'
)
if
not
os
.
path
.
exists
(
app
.
config
[
'
data_path
'
]):
os
.
makedirs
(
app
.
config
[
'
data_path
'
])
...
...
This diff is collapsed.
Click to expand it.
api.wsgi
+
5
−
5
View file @
a3c2d85f
...
...
@@ -8,7 +8,7 @@ import argparse
import uwsgidecorators
import api
import
internims
client
import
central
client
os.environ['PYTHON_EGG_CACHE'] = '/tmp/python_egg_cache'
os.umask(0o022)
...
...
@@ -78,13 +78,13 @@ else:
fail_count = 0
@uwsgidecorators.timer(60)
def
internims
client_timer(signum):
def
central
client_timer(signum):
global fail_count
if not
internims
client.update(application.db, args.api_uri, args.site_name, args.site_id, args.ssl_cert, args.central_uri):
if not
central
client.update(application.db, args.api_uri, args.site_name, args.site_id, args.ssl_cert, args.central_uri):
fail_count += 1
else:
fail_count = 0
if fail_count == 3:
log.debug('
InterNIMS
unreachable, purging all remotes info')
internims
client.clean_remotes(application.db)
log.debug('
scitran central
unreachable, purging all remotes info')
central
client.clean_remotes(application.db)
This diff is collapsed.
Click to expand it.
internims
client.py
→
central
client.py
+
6
−
6
View file @
a3c2d85f
...
...
@@ -12,7 +12,7 @@ local users are permitted to access data in other instances.
import
logging
import
logging.config
logging
.
basicConfig
()
log
=
logging
.
getLogger
(
'
internims
'
)
log
=
logging
.
getLogger
(
'
centralclient
'
)
logging
.
getLogger
(
'
requests
'
).
setLevel
(
logging
.
WARNING
)
# silence Requests library logging
import
re
...
...
@@ -20,7 +20,7 @@ import json
import
requests
def
update
(
db
,
api_uri
,
site_name
,
site_id
,
ssl_cert
,
internims
_url
):
def
update
(
db
,
api_uri
,
site_name
,
site_id
,
ssl_cert
,
central
_url
):
"""
Send is-alive signal to central peer registry.
"""
proj_userlist
=
[
p
[
'
permissions
'
]
for
p
in
db
.
projects
.
find
(
None
,
{
'
_id
'
:
False
,
'
permissions._id
'
:
True
,
'
permissions.site
'
:
True
})]
col_userlist
=
[
c
[
'
permissions
'
]
for
c
in
db
.
collections
.
find
(
None
,
{
'
_id
'
:
False
,
'
permissions._id
'
:
True
,
'
permissions.site
'
:
True
})]
...
...
@@ -31,7 +31,7 @@ def update(db, api_uri, site_name, site_id, ssl_cert, internims_url):
payload
=
json
.
dumps
({
'
_id
'
:
site_id
,
'
api_uri
'
:
api_uri
,
'
users
'
:
remote_users
,
'
name
'
:
site_name
})
try
:
r
=
requests
.
post
(
internims
_url
,
data
=
payload
,
cert
=
ssl_cert
)
r
=
requests
.
post
(
central
_url
,
data
=
payload
,
cert
=
ssl_cert
)
except
requests
.
exceptions
.
ConnectionError
:
log
.
debug
(
'
SDMC is not reachable
'
)
else
:
...
...
@@ -87,7 +87,7 @@ if __name__ == '__main__':
import
argparse
arg_parser
=
argparse
.
ArgumentParser
()
arg_parser
.
add_argument
(
'
--
internims
_url
'
,
help
=
'
Scitran Central API URL
'
,
default
=
'
https://sdmc.scitran.io
'
)
arg_parser
.
add_argument
(
'
--
central
_url
'
,
help
=
'
Scitran Central API URL
'
,
default
=
'
https://sdmc.scitran.io
'
)
arg_parser
.
add_argument
(
'
--db_uri
'
,
help
=
'
DB URI
'
,
required
=
True
)
arg_parser
.
add_argument
(
'
--api_uri
'
,
help
=
'
API URL, without http:// or https://
'
,
required
=
True
)
arg_parser
.
add_argument
(
'
--site_id
'
,
help
=
'
instance hostname (used as unique ID)
'
,
required
=
True
)
...
...
@@ -106,11 +106,11 @@ if __name__ == '__main__':
fail_count
=
0
while
True
:
if
not
update
(
db
,
args
.
api_uri
,
args
.
site_name
,
args
.
site_id
,
args
.
ssl_cert
,
args
.
internims
_url
):
if
not
update
(
db
,
args
.
api_uri
,
args
.
site_name
,
args
.
site_id
,
args
.
ssl_cert
,
args
.
central
_url
):
fail_count
+=
1
else
:
fail_count
=
0
if
fail_count
==
3
:
log
.
debug
(
'
InterNIMS
unreachable, purging all remotes info
'
)
log
.
debug
(
'
scitran central
unreachable, purging all remotes info
'
)
clean_remotes
(
db
)
time
.
sleep
(
args
.
sleeptime
)
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