Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
518c7588
Commit
518c7588
authored
Sep 24, 2015
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to specify log file in configuration file, and expand ~(user) construction
parent
32b2d173
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
55 deletions
+27
-55
neo.conf
neo.conf
+3
-0
neo/lib/config.py
neo/lib/config.py
+18
-5
neo/scripts/neoadmin.py
neo/scripts/neoadmin.py
+2
-14
neo/scripts/neomaster.py
neo/scripts/neomaster.py
+2
-18
neo/scripts/neostorage.py
neo/scripts/neostorage.py
+2
-18
No files found.
neo.conf
View file @
518c7588
...
@@ -53,6 +53,9 @@ partitions: 12
...
@@ -53,6 +53,9 @@ partitions: 12
# Admin node
# Admin node
[
admin
]
[
admin
]
bind
:
127
.
0
.
0
.
1
:
9999
bind
:
127
.
0
.
0
.
1
:
9999
# Paths to log files can be specified here, but be careful not to do it in a
# common section. ~ and ~user constructions are expanded.
;
logfile
: ~/
log
/
admin
.
log
# Master nodes
# Master nodes
[
master
]
[
master
]
...
...
neo/lib/config.py
View file @
518c7588
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
from
optparse
import
OptionParser
from
optparse
import
OptionParser
from
ConfigParser
import
SafeConfigParser
,
NoOptionError
from
ConfigParser
import
SafeConfigParser
,
NoOptionError
from
.
import
util
from
.
import
util
...
@@ -44,14 +45,18 @@ class ConfigurationManager(object):
...
@@ -44,14 +45,18 @@ class ConfigurationManager(object):
command line arguments
command line arguments
"""
"""
def
__init__
(
self
,
defaults
,
config_file
,
section
,
argument_list
):
def
__init__
(
self
,
defaults
,
options
,
section
):
self
.
argument_list
=
options
=
{
k
:
v
for
k
,
v
in
options
.
__dict__
.
iteritems
()
if
v
is
not
None
}
self
.
defaults
=
defaults
self
.
defaults
=
defaults
self
.
argument_list
=
argument_list
config_file
=
options
.
pop
(
'file'
,
None
)
self
.
parser
=
None
if
config_file
:
if
config_file
is
not
None
:
self
.
parser
=
SafeConfigParser
(
defaults
)
self
.
parser
=
SafeConfigParser
(
defaults
)
self
.
parser
.
read
(
config_file
)
self
.
parser
.
read
(
config_file
)
self
.
section
=
section
else
:
self
.
parser
=
None
self
.
section
=
options
.
pop
(
'section'
,
section
)
def
__get
(
self
,
key
,
optional
=
False
):
def
__get
(
self
,
key
,
optional
=
False
):
value
=
self
.
argument_list
.
get
(
key
)
value
=
self
.
argument_list
.
get
(
key
)
...
@@ -67,6 +72,14 @@ class ConfigurationManager(object):
...
@@ -67,6 +72,14 @@ class ConfigurationManager(object):
raise
RuntimeError
(
"Option '%s' is undefined'"
%
(
key
,
))
raise
RuntimeError
(
"Option '%s' is undefined'"
%
(
key
,
))
return
value
return
value
def
__getPath
(
self
,
*
args
,
**
kw
):
path
=
self
.
__get
(
*
args
,
**
kw
)
if
path
:
return
os
.
path
.
expanduser
(
path
)
def
getLogfile
(
self
):
return
self
.
__getPath
(
'logfile'
,
True
)
def
getMasters
(
self
):
def
getMasters
(
self
):
""" Get the master node list except itself """
""" Get the master node list except itself """
masters
=
self
.
__get
(
'masters'
)
masters
=
self
.
__get
(
'masters'
)
...
...
neo/scripts/neoadmin.py
View file @
518c7588
...
@@ -32,22 +32,10 @@ defaults = dict(
...
@@ -32,22 +32,10 @@ defaults = dict(
def
main
(
args
=
None
):
def
main
(
args
=
None
):
# build configuration dict from command line options
# build configuration dict from command line options
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
arguments
=
dict
(
config
=
ConfigurationManager
(
defaults
,
options
,
'admin'
)
uuid
=
options
.
uuid
,
cluster
=
options
.
cluster
,
masters
=
options
.
masters
,
bind
=
options
.
bind
,
)
config
=
ConfigurationManager
(
defaults
,
options
.
file
,
options
.
section
or
'admin'
,
arguments
,
)
# setup custom logging
# setup custom logging
logging
.
setup
(
options
.
logfile
)
logging
.
setup
(
config
.
getLogfile
()
)
# and then, load and run the application
# and then, load and run the application
from
neo.admin.app
import
Application
from
neo.admin.app
import
Application
...
...
neo/scripts/neomaster.py
View file @
518c7588
...
@@ -43,26 +43,10 @@ defaults = dict(
...
@@ -43,26 +43,10 @@ defaults = dict(
def
main
(
args
=
None
):
def
main
(
args
=
None
):
# build configuration dict from command line options
# build configuration dict from command line options
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
arguments
=
dict
(
config
=
ConfigurationManager
(
defaults
,
options
,
'master'
)
uuid
=
options
.
uuid
or
None
,
bind
=
options
.
bind
,
cluster
=
options
.
cluster
,
masters
=
options
.
masters
,
replicas
=
options
.
replicas
,
partitions
=
options
.
partitions
,
autostart
=
options
.
autostart
,
upstream_cluster
=
options
.
upstream_cluster
,
upstream_masters
=
options
.
upstream_masters
,
)
config
=
ConfigurationManager
(
defaults
,
options
.
file
,
options
.
section
or
'master'
,
arguments
,
)
# setup custom logging
# setup custom logging
logging
.
setup
(
options
.
logfile
)
logging
.
setup
(
config
.
getLogfile
()
)
# and then, load and run the application
# and then, load and run the application
from
neo.master.app
import
Application
from
neo.master.app
import
Application
...
...
neo/scripts/neostorage.py
View file @
518c7588
...
@@ -45,26 +45,10 @@ def main(args=None):
...
@@ -45,26 +45,10 @@ def main(args=None):
# letting it slip through in a long option list.
# letting it slip through in a long option list.
# We should drop support configation files to make such check useful.
# We should drop support configation files to make such check useful.
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
arguments
=
dict
(
config
=
ConfigurationManager
(
defaults
,
options
,
'storage'
)
uuid
=
options
.
uuid
,
bind
=
options
.
bind
,
cluster
=
options
.
cluster
,
masters
=
options
.
masters
,
database
=
options
.
database
,
engine
=
options
.
engine
,
reset
=
options
.
reset
,
adapter
=
options
.
adapter
,
wait
=
options
.
wait
,
)
config
=
ConfigurationManager
(
defaults
,
options
.
file
,
options
.
section
or
'storage'
,
arguments
,
)
# setup custom logging
# setup custom logging
logging
.
setup
(
options
.
logfile
)
logging
.
setup
(
config
.
getLogfile
()
)
# and then, load and run the application
# and then, load and run the application
from
neo.storage.app
import
Application
from
neo.storage.app
import
Application
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment