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
a01f9269
Commit
a01f9269
authored
9 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
Improve persistent path variables
parent
72a3dc6b
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/config.py
+2
-0
2 additions, 0 deletions
api/config.py
bin/bootstrap.py
+1
-4
1 addition, 4 deletions
bin/bootstrap.py
bin/run.sh
+17
-8
17 additions, 8 deletions
bin/run.sh
sample.config
+2
-0
2 additions, 0 deletions
sample.config
with
22 additions
and
12 deletions
api/config.py
+
2
−
0
View file @
a01f9269
...
...
@@ -68,6 +68,8 @@ for outer_key, scoped_config in __config.iteritems():
value
=
None
__config
[
outer_key
][
inner_key
]
=
value
if
not
os
.
path
.
exists
(
__config
[
'
persistent
'
][
'
data_path
'
]):
os
.
makedirs
(
__config
[
'
persistent
'
][
'
data_path
'
])
db
=
pymongo
.
MongoClient
(
__config
[
'
persistent
'
][
'
db_uri
'
],
j
=
True
,
connectTimeoutMS
=
2000
,
serverSelectionTimeoutMS
=
3000
).
get_default_database
()
...
...
This diff is collapsed.
Click to expand it.
bin/bootstrap.py
+
1
−
4
View file @
a01f9269
...
...
@@ -72,8 +72,6 @@ example:
def
data
(
args
):
if
not
os
.
path
.
exists
(
args
.
storage_path
):
os
.
makedirs
(
args
.
storage_path
)
log
.
info
(
'
inspecting %s
'
%
args
.
path
)
files
=
[]
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
args
.
path
):
...
...
@@ -97,7 +95,7 @@ def data(args):
for
chunk
in
iter
(
lambda
:
fd
.
read
(
2
**
20
),
''
):
hash_
.
update
(
chunk
)
computed_hash
=
hash_
.
hexdigest
()
destpath
=
os
.
path
.
join
(
args
.
storage
_path
,
util
.
path_from_hash
(
computed_hash
))
destpath
=
os
.
path
.
join
(
config
.
get_item
(
'
persistent
'
,
'
data
_path
'
)
,
util
.
path_from_hash
(
computed_hash
))
dir_destpath
=
os
.
path
.
dirname
(
destpath
)
filename
=
os
.
path
.
basename
(
filepath
)
if
not
os
.
path
.
exists
(
dir_destpath
):
...
...
@@ -152,7 +150,6 @@ data_parser = subparsers.add_parser(
)
data_parser
.
add_argument
(
'
-c
'
,
'
--copy
'
,
action
=
'
store_true
'
,
help
=
'
copy data instead of moving it
'
)
data_parser
.
add_argument
(
'
path
'
,
help
=
'
filesystem path to data
'
)
data_parser
.
add_argument
(
'
storage_path
'
,
help
=
'
filesystem path to sorted data
'
)
data_parser
.
set_defaults
(
func
=
data
)
args
=
parser
.
parse_args
()
...
...
This diff is collapsed.
Click to expand it.
bin/run.sh
+
17
−
8
View file @
a01f9269
...
...
@@ -8,12 +8,12 @@ cd "$( dirname "${BASH_SOURCE[0]}" )/.."
echo
()
{
builtin echo
"[SCITRAN]
$@
"
;
}
set
-o
allexport
if
[
"$#"
-eq
1
]
;
then
EXISTING_ENV
=
$(
env
|
grep
"SCITRAN_"
|
cat
)
set
-o
allexport
source
"
$1
"
eval
"
$EXISTING_ENV
"
set
+o allexport
fi
if
[
"$#"
-gt
1
]
;
then
echo
"Usage:
$0
[config file]"
...
...
@@ -40,6 +40,12 @@ fi
if
[
-z
"
$SCITRAN_PERSISTENT_PATH
"
]
;
then
SCITRAN_PERSISTENT_PATH
=
"./persistent"
fi
if
[
-z
"
$SCITRAN_PERSISTENT_DATA_PATH
"
]
;
then
SCITRAN_PERSISTENT_DATA_PATH
=
"
$SCITRAN_PERSISTENT_PATH
/data"
fi
if
[
-z
"
$SCITRAN_PERSISTENT_DB_PATH
"
]
;
then
SCITRAN_PERSISTENT_DB_PATH
=
"
$SCITRAN_PERSISTENT_PATH
/db"
fi
if
[
-z
"
$SCITRAN_PERSISTENT_DB_PORT
"
]
;
then
SCITRAN_PERSISTENT_DB_PORT
=
"9001"
fi
...
...
@@ -47,12 +53,14 @@ if [ -z "$SCITRAN_PERSISTENT_DB_URI" ]; then
SCITRAN_PERSISTENT_DB_URI
=
"mongodb://localhost:
$SCITRAN_PERSISTENT_DB_PORT
/scitran"
fi
set
+o allexport
if
[
-f
"
$SCITRAN_PERSISTENT_PATH
/
db/
mongod.lock"
]
;
then
if
[
-f
"
$SCITRAN_PERSISTENT_
DB_
PATH
/mongod.lock"
]
;
then
BOOTSTRAP_USERS
=
0
else
echo
"Creating database location at
$SCITRAN_PERSISTENT_PATH
/db
"
mkdir
-p
$SCITRAN_PERSISTENT_PATH
/db
echo
"Creating database location at
$SCITRAN_PERSISTENT_
DB_
PATH
"
mkdir
-p
$SCITRAN_PERSISTENT_
DB_
PATH
if
!
[
-f
"
$SCITRAN_SYSTEM_BOOTSTRAP
"
]
;
then
echo
"Aborting. Please create
$SCITRAN_SYSTEM_BOOTSTRAP
from bootstrap.json.sample."
exit
1
...
...
@@ -118,7 +126,7 @@ pip install -U -r requirements.txt
# Launch mongod
mongod
--dbpath
$SCITRAN_PERSISTENT_PATH
/db
--smallfiles
--port
$SCITRAN_PERSISTENT_DB_PORT
&
mongod
--dbpath
$SCITRAN_PERSISTENT_
DB_
PATH
--smallfiles
--port
$SCITRAN_PERSISTENT_DB_PORT
&
MONGO_PID
=
$!
# Set python path so scripts can work
...
...
@@ -147,12 +155,13 @@ else
fi
builtin echo
"
$TESTDATA_VERSION
"
>
"
$SCITRAN_PERSISTENT_PATH
/.testdata_version"
if
[
-
d
"
$SCITRAN_PERSISTENT_
PATH
/data
"
]
;
then
if
[
-
f
"
$SCITRAN_PERSISTENT_
DATA_PATH
/.bootstrapped
"
]
;
then
echo
"Persistence store exists at
$SCITRAN_PERSISTENT_PATH
/data. Not bootstrapping data. Remove to re-bootstrap."
else
echo
"Bootstrapping testdata"
bin/bootstrap.py data
--copy
$SCITRAN_PERSISTENT_PATH
/testdata
$SCITRAN_PERSISTENT_PATH
/data
bin/bootstrap.py data
--copy
$SCITRAN_PERSISTENT_PATH
/testdata
echo
"Bootstrapped testdata"
touch
"
$SCITRAN_PERSISTENT_DATA_PATH
/.bootstrapped"
fi
...
...
This diff is collapsed.
Click to expand it.
sample.config
+
2
−
0
View file @
a01f9269
...
...
@@ -17,6 +17,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_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