Skip to content

Commit

Permalink
make conf file optional
Browse files Browse the repository at this point in the history
  • Loading branch information
yujunglo committed Jan 14, 2016
1 parent 80ad81f commit a5a1657
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deploy-agent/deployd/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-e', '--server_stage', dest='stage', default='prod',
help="This option is deprecated")
parser.add_argument('-f', '--config-file', dest='config_file', required=False, default='deployd/conf/agent.conf',
parser.add_argument('-f', '--config-file', dest='config_file', required=False,
help="the deploy agent config file path.")
parser.add_argument('-d', '--daemon', dest="daemon", action='store_true')
parser.add_argument('-n', '--host_name', dest="hostname", required=False, default=None)
Expand Down
6 changes: 5 additions & 1 deletion deploy-agent/deployd/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ def __init__(self, filenames=None, config_reader=None):
self._config_reader = config_reader
return

self._config_reader = SafeConfigParser()
if not filenames:
return

if not os.path.exists(filenames):
print('Cannot find config files: {}'.format(filenames))
exit_abruptly(1)

self._filenames = filenames
self._config_reader = SafeConfigParser()
loaded_filenames = self._config_reader.read(self._filenames)
if len(loaded_filenames) == 0:
print('Cannot read config files: {}'.format(self._filenames))
exit_abruptly(1)

def get_config_filename(self):
return self._filenames
Expand Down

0 comments on commit a5a1657

Please sign in to comment.