Skip to content

Commit

Permalink
[core] remove start/stop/restart commands
Browse files Browse the repository at this point in the history
All of these are handled by Supervisord, which launches the processes in
the foreground. This is a complete legacy code, and some people still
use it wrongly.
This commits deletes these options, removing the risk for everyone to
misuse them.
  • Loading branch information
degemer committed Nov 7, 2016
1 parent ed3bf61 commit 984aab6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 138 deletions.
33 changes: 5 additions & 28 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ def main():
hostname = get_hostname(agentConfig)
in_developer_mode = agentConfig.get('developer_mode')
COMMANDS_AGENT = [
'start',
'stop',
'restart',
'status',
'foreground',
]
Expand Down Expand Up @@ -401,17 +398,9 @@ def main():
if command in START_COMMANDS:
log.info('Agent version %s' % get_version())

if 'start' == command:
log.info('Start daemon')
agent.start()

elif 'stop' == command:
log.info('Stop daemon')
agent.stop()

elif 'restart' == command:
log.info('Restart daemon')
agent.restart()
if command in ['start', 'stop', 'restart']:
logging.error('Please use supervisor to manage the agent')
return 1

elif 'status' == command:
agent.status()
Expand All @@ -420,20 +409,8 @@ def main():
return Agent.info(verbose=options.verbose)

elif 'foreground' == command:
if autorestart:
# Set-up the supervisor callbacks and fork it.
logging.info('Running Agent with auto-restart ON')

def child_func():
agent.start(foreground=True)

def parent_func():
agent.start_event = False

AgentSupervisor.start(parent_func, child_func)
else:
# Run in the standard foreground.
agent.start(foreground=True)
# Run in the standard foreground.
agent.start(foreground=True)

elif 'check' == command:
if len(args) < 2:
Expand Down
17 changes: 6 additions & 11 deletions dogstatsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,6 @@ def main(config_path=None):
deprecate_old_command_line_tools()

COMMANDS_START_DOGSTATSD = [
'start',
'stop',
'restart',
'status'
]

Expand All @@ -570,20 +567,18 @@ def main(config_path=None):
daemon.start(foreground=True)
return 0

# Otherwise, we're process the deamon command.
# Otherwise, let's display the info/status/an error.
else:
command = args[0]

if command == 'start':
daemon.start()
elif command == 'stop':
daemon.stop()
elif command == 'restart':
daemon.restart()
elif command == 'status':
if command == 'status':
daemon.status()
elif command == 'info':
return Dogstatsd.info()
elif command in ['start', 'stop', 'restart']:
sys.stderr.write('Please use supervisor to manage dogstatsd')
parser.print_help()
return 1
else:
sys.stderr.write("Unknown command: %s\n\n" % command)
parser.print_help()
Expand Down
99 changes: 0 additions & 99 deletions tests/core/test_autorestart.py

This file was deleted.

0 comments on commit 984aab6

Please sign in to comment.