Skip to content

Commit d5e65d0

Browse files
committed
fix: moved the initialization of the Monitoring before calling self.initialize
1 parent a8e36c4 commit d5e65d0

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/DIRAC/Core/Base/AgentModule.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
9898
the configuration Option 'shifterProxy' must be set, a default may be given
9999
in the initialize() method.
100100
"""
101-
if baseAgentName and agentName == baseAgentName:
102-
self.log = gLogger
103-
standaloneModule = True
104-
else:
105-
self.log = gLogger.getSubLogger(agentName, child=False)
106-
standaloneModule = False
101+
self.log = gLogger.getSubLogger(agentName, child=False)
107102

108103
self.__basePath = gConfig.getValue("/LocalSite/InstancePath", rootPath)
109104
self.__agentModule = None
@@ -115,7 +110,6 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
115110
"loadName": loadName,
116111
"section": PathFinder.getAgentSection(agentName),
117112
"loadSection": PathFinder.getAgentSection(loadName),
118-
"standalone": standaloneModule,
119113
"cyclesDone": 0,
120114
"totalElapsedTime": 0,
121115
"setup": gConfig.getValue("/DIRAC/Setup", "Unknown"),
@@ -171,6 +165,9 @@ def am_initialize(self, *initArgs):
171165
This is called by the AgentReactor, should not be overridden.
172166
"""
173167
agentName = self.am_getModuleParam("fullName")
168+
169+
self.__initializeMonitor()
170+
174171
result = self.initialize(*initArgs)
175172
if not isReturnStructure(result):
176173
return S_ERROR("initialize must return S_OK/S_ERROR")
@@ -182,8 +179,6 @@ def am_initialize(self, *initArgs):
182179
# Set the work directory in an environment variable available to subprocesses if needed
183180
os.environ["AGENT_WORKDIRECTORY"] = workDirectory
184181

185-
self.__initializeMonitor()
186-
187182
self.__moduleProperties["shifterProxy"] = self.am_getOption("shifterProxy")
188183
if len(self.__moduleProperties["executors"]) < 1:
189184
return S_ERROR("At least one executor method has to be defined")
@@ -295,6 +290,7 @@ def __initializeMonitor(self):
295290
# if the "EnableActivityMonitoring" flag in "yes" or "true" in the cfg file.
296291
self.activityMonitoring = Operations().getValue("EnableActivityMonitoring", False)
297292
if self.activityMonitoring:
293+
self.log.debug("Using activity monitoring")
298294
# The import needs to be here because of the CS must be initialized before importing
299295
# this class (see https://github.com/DIRACGrid/DIRAC/issues/4793)
300296
from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter

0 commit comments

Comments
 (0)