diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-11-09 13:32:22 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-11-09 13:32:22 +0200 |
| commit | 60890e054075d92be557f9a7da6f29b5e8ec9f90 (patch) | |
| tree | 56ce974b52eeeae5e60ee0eb2346cd5f7e420004 | |
| parent | a4c02f07573640e2c1b88cb7315293f3df2c2c07 (diff) | |
config-dir command line arg
| -rw-r--r-- | src-py/rhizi_server.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src-py/rhizi_server.py b/src-py/rhizi_server.py index 5393a61e..c9bc65e6 100644 --- a/src-py/rhizi_server.py +++ b/src-py/rhizi_server.py @@ -1,8 +1,9 @@ import logging import json import util +import os import neo4j_util - +import argparse import db_controller as dbc import rhizi_api @@ -15,6 +16,9 @@ class Config(object): def init_from_file(file_path): ret = Config() + if False == os.path.exists(file_path): + raise Exception('config file not found: ' + file_path) + with open(file_path, 'r') as f: cfg = json.loads(f.read()) @@ -50,9 +54,15 @@ class RhiziServer(object): if __name__ == "__main__": + p = argparse.ArgumentParser(description='rhizi-server') + p.add_argument('--config-dir', help='path to Rhizi config dir') + args = p.parse_args() + + cfg_dir = args.config_dir + init_logging() - cfg = Config.init_from_file('res/etc/rhizi-server.conf') + cfg = Config.init_from_file(os.path.join(cfg_dir, 'rhizi-server.conf')) db_ctl = dbc.DB_Controller(cfg) rhizi_api.db_ctl = db_ctl |
