Skip to content

Commit

Permalink
[core] hard-deprecate start/stop/restart/status
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 still allows these options, but only in developer mode,
removing the risk for most people to misuse them.

It also removes the deprecation notice for the old command line
executables: they are not shipped anymore, and the main reason why they
were deprecated was the start/stop/restart/status commands. Since this
commit takes care of that, the notices are not needed anymore.
  • Loading branch information
degemer committed Nov 8, 2016
1 parent ed3bf61 commit 7580eba
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 134 deletions.
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.

0 comments on commit 7580eba

Please sign in to comment.