Skip to content

Commit 5e8e4f7

Browse files
authored
Remove check for pidfile on windows. (#3574)
Change logging output for registry entries that aren't found. Mostly, they're not expected to be present and they create confusion
1 parent b4a9ecf commit 5e8e4f7

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

daemon.py

+19-14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import time
2323

2424
# project
25+
from utils.platform import Platform
2526
from utils.process import is_my_process
2627
from utils.subprocess_output import subprocess
2728
from config import get_logging_config
@@ -231,22 +232,26 @@ def daemonize(self):
231232

232233
def start(self, foreground=False):
233234
log.info("Starting")
234-
pid = self.pid()
235+
if not Platform.is_windows():
236+
pid = self.pid()
237+
238+
if pid:
239+
# Check if the pid in the pidfile corresponds to a running process
240+
# and if psutil is installed, check if it's a datadog-agent one
241+
if is_my_process(pid):
242+
log.error("Not starting, another instance is already running"
243+
" (using pidfile {0})".format(self.pidfile))
244+
sys.exit(1)
245+
else:
246+
log.warn("pidfile doesn't contain the pid of an agent process."
247+
' Starting normally')
235248

236-
if pid:
237-
# Check if the pid in the pidfile corresponds to a running process
238-
# and if psutil is installed, check if it's a datadog-agent one
239-
if is_my_process(pid):
240-
log.error("Not starting, another instance is already running"
241-
" (using pidfile {0})".format(self.pidfile))
242-
sys.exit(1)
243-
else:
244-
log.warn("pidfile doesn't contain the pid of an agent process."
245-
' Starting normally')
249+
if not foreground:
250+
self.daemonize()
251+
self.write_pidfile()
252+
else:
253+
log.debug("Skipping pidfile check for Windows")
246254

247-
if not foreground:
248-
self.daemonize()
249-
self.write_pidfile()
250255
self.run()
251256

252257
def stop(self):

utils/windows_configuration.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ def get_registry_conf(agentConfig):
4444
if option != '':
4545
registry_conf[attribute] = option
4646
except (ImportError, WindowsError) as e:
47-
log.error('Unable to get config keys from Registry: %s', e)
47+
# don't log this as an error. Since the keys are deleted after
48+
# they're used, they're almost certain to not be there.
49+
# however, log as `info` so it will show by default after install
50+
# (i.e. before user has had a chance to change the config file)
51+
# so it can be seen if necessary
52+
log.info('Unable to get config keys from Registry (this is probably OK): %s', e)
4853

4954
return registry_conf
5055

@@ -87,7 +92,9 @@ def get_sdk_integration_paths():
8792
except WindowsError as e:
8893
log.error('Unable to get keys from Registry for %s: %s', integration_name, e)
8994
except WindowsError as e:
90-
log.error('Unable to get config keys from Registry: %s', e)
95+
# don't log this as an error. Unless someone has installed a standalone
96+
# integration, this key won't be present.
97+
log.debug('Unable to get config keys from Registry: %s', e)
9198

9299
return integrations
93100

0 commit comments

Comments
 (0)