Skip to content

Commit

Permalink
some slight logic/syntax fixes for #336
Browse files Browse the repository at this point in the history
  • Loading branch information
pcockwell committed Jan 10, 2013
1 parent 3c58c8a commit 7dfbcc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _handle_sigterm(self, signum, frame):
if self.collector:
self.collector.stop()

def run(self):
def run(self, config=None):
"""Main loop of the collector"""

# Gracefully exit on sigterm.
Expand All @@ -73,7 +73,10 @@ def run(self):
CollectorStatus().persist()

# Intialize the collector.
agentConfig = self._set_agent_config_hostname(get_config(parse_args=true))
if not config:
config = get_config(parse_args=True)

agentConfig = self._set_agent_config_hostname(config)
systemStats = get_system_stats()
emitters = self._get_emitters(agentConfig)
self.collector = Collector(agentConfig, emitters, systemStats)
Expand Down Expand Up @@ -168,7 +171,7 @@ def setup_logging(agentConfig):

def main():
options, args = get_parsed_args()
agentConfig = get_config(options=options, args=args)
agentConfig = get_config(options=options)

# Logging
setup_logging(agentConfig)
Expand Down Expand Up @@ -216,7 +219,7 @@ def main():

elif 'foreground' == command:
logging.info('Running in foreground')
agent.run()
agent.run(config=agentConfig)

# Commands that don't need the agent to be initialized.
else:
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_config_path(cfg_path=None, os_name=None):
sys.stderr.write("Please supply a configuration file at %s or in the directory where the agent is currently deployed.\n" % str(exc))
sys.exit(3)

def get_config(parse_args = False, cfg_path=None, init_logging=False, options=None, args=None):
def get_config(parse_args=False, cfg_path=None, init_logging=False, options=None):
if parse_args:
options, args = get_parsed_args()

Expand Down

0 comments on commit 7dfbcc7

Please sign in to comment.