Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
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
Show 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
# Admin node
[
admin
]
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
]
...
...
neo/lib/config.py
View file @
518c7588
...
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
from
optparse
import
OptionParser
from
ConfigParser
import
SafeConfigParser
,
NoOptionError
from
.
import
util
...
...
@@ -44,14 +45,18 @@ class ConfigurationManager(object):
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
.
argument_list
=
argument_list
self
.
parser
=
None
if
config_file
is
not
None
:
config_file
=
options
.
pop
(
'file'
,
None
)
if
config_file
:
self
.
parser
=
SafeConfigParser
(
defaults
)
self
.
parser
.
read
(
config_file
)
self
.
section
=
section
else
:
self
.
parser
=
None
self
.
section
=
options
.
pop
(
'section'
,
section
)
def
__get
(
self
,
key
,
optional
=
False
):
value
=
self
.
argument_list
.
get
(
key
)
...
...
@@ -67,6 +72,14 @@ class ConfigurationManager(object):
raise
RuntimeError
(
"Option '%s' is undefined'"
%
(
key
,
))
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
):
""" Get the master node list except itself """
masters
=
self
.
__get
(
'masters'
)
...
...
neo/scripts/neoadmin.py
View file @
518c7588
...
...
@@ -32,22 +32,10 @@ defaults = dict(
def
main
(
args
=
None
):
# build configuration dict from command line options
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
arguments
=
dict
(
uuid
=
options
.
uuid
,
cluster
=
options
.
cluster
,
masters
=
options
.
masters
,
bind
=
options
.
bind
,
)
config
=
ConfigurationManager
(
defaults
,
options
.
file
,
options
.
section
or
'admin'
,
arguments
,
)
config
=
ConfigurationManager
(
defaults
,
options
,
'admin'
)
# setup custom logging
logging
.
setup
(
options
.
logfile
)
logging
.
setup
(
config
.
getLogfile
()
)
# and then, load and run the application
from
neo.admin.app
import
Application
...
...
neo/scripts/neomaster.py
View file @
518c7588
...
...
@@ -43,26 +43,10 @@ defaults = dict(
def
main
(
args
=
None
):
# build configuration dict from command line options
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
arguments
=
dict
(
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
,
)
config
=
ConfigurationManager
(
defaults
,
options
,
'master'
)
# setup custom logging
logging
.
setup
(
options
.
logfile
)
logging
.
setup
(
config
.
getLogfile
()
)
# and then, load and run the application
from
neo.master.app
import
Application
...
...
neo/scripts/neostorage.py
View file @
518c7588
...
...
@@ -45,26 +45,10 @@ def main(args=None):
# letting it slip through in a long option list.
# We should drop support configation files to make such check useful.
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
arguments
=
dict
(
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
,
)
config
=
ConfigurationManager
(
defaults
,
options
,
'storage'
)
# setup custom logging
logging
.
setup
(
options
.
logfile
)
logging
.
setup
(
config
.
getLogfile
()
)
# and then, load and run the 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