Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] hard-deprecate start/stop/restart/status commands #3004

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
PID_DIR = None
WATCHDOG_MULTIPLIER = 10
RESTART_INTERVAL = 4 * 24 * 60 * 60 # Defaults to 4 days
START_COMMANDS = ['start', 'restart', 'foreground']
DD_AGENT_COMMANDS = ['check', 'flare', 'jmx']

DEFAULT_COLLECTOR_PROFILE_INTERVAL = 20

Expand Down Expand Up @@ -362,6 +360,7 @@ def main():
autorestart = agentConfig.get('autorestart', False)
hostname = get_hostname(agentConfig)
in_developer_mode = agentConfig.get('developer_mode')

COMMANDS_AGENT = [
'start',
'stop',
Expand Down Expand Up @@ -389,18 +388,14 @@ def main():
sys.stderr.write("Unknown command: %s\n" % command)
return 3

# Deprecation notice
if command not in DD_AGENT_COMMANDS:
# Will become an error message and exit after deprecation period
from utils.deprecations import deprecate_old_command_line_tools
deprecate_old_command_line_tools()
# TODO: actually kill the start/stop/restart/status command for 5.11
if command in ['start', 'stop', 'restart', 'status'] and not in_developer_mode:
logging.error('Please use supervisor to manage the agent')
return 1

if command in COMMANDS_AGENT:
agent = Agent(PidFile(PID_NAME, PID_DIR).get_path(), autorestart, in_developer_mode=in_developer_mode)

if command in START_COMMANDS:
log.info('Agent version %s' % get_version())

if 'start' == command:
log.info('Start daemon')
agent.start()
Expand All @@ -420,6 +415,7 @@ def main():
return Agent.info(verbose=options.verbose)

elif 'foreground' == command:
log.info('Agent version %s' % get_version())
if autorestart:
# Set-up the supervisor callbacks and fork it.
logging.info('Running Agent with auto-restart ON')
Expand Down
4 changes: 0 additions & 4 deletions ddagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,6 @@ def sigterm_handler(signum, frame):


def main():
# Deprecation notice
from utils.deprecations import deprecate_old_command_line_tools
deprecate_old_command_line_tools()

define("sslcheck", default=1, help="Verify SSL hostname, on by default")
define("use_simple_http_client", default=0, help="Use Tornado SimpleHTTPClient instead of CurlAsyncHTTPClient")
args = parse_command_line()
Expand Down
11 changes: 7 additions & 4 deletions dogstatsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,6 @@ def init(config_path=None, use_watchdog=False, use_forwarder=False, args=None):

def main(config_path=None):
""" The main entry point for the unix version of dogstatsd. """
# Deprecation notice
from utils.deprecations import deprecate_old_command_line_tools
deprecate_old_command_line_tools()

COMMANDS_START_DOGSTATSD = [
'start',
'stop',
Expand All @@ -560,10 +556,12 @@ def main(config_path=None):
dest="use_forwarder", default=False)
opts, args = parser.parse_args()

in_developer_mode = False
if not args or args[0] in COMMANDS_START_DOGSTATSD:
reporter, server, cnf = init(config_path, use_watchdog=True, use_forwarder=opts.use_forwarder, args=args)
daemon = Dogstatsd(PidFile(PID_NAME, PID_DIR).get_path(), server, reporter,
cnf.get('autorestart', False))
in_developer_mode = cnf.get('developer_mode')

# If no args were passed in, run the server in the foreground.
if not args:
Expand All @@ -574,6 +572,11 @@ def main(config_path=None):
else:
command = args[0]

# TODO: actually kill the start/stop/restart/status command for 5.11
if command in ['start', 'stop', 'restart', 'status'] and not in_developer_mode:
logging.error('Please use supervisor to manage the agent')
return 1

if command == 'start':
daemon.start()
elif command == 'stop':
Expand Down
99 changes: 0 additions & 99 deletions tests/core/test_autorestart.py

This file was deleted.

17 changes: 0 additions & 17 deletions utils/deprecations.py

This file was deleted.