Skip to content

Commit 5436f0d

Browse files
committed
Agent: Move stop signal check to an earlier point
1 parent e4e9f70 commit 5436f0d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

monkey/infection_monkey/monkey.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ def _log_arguments(args):
214214
logger.info(f"Agent started with arguments: {arg_string}")
215215

216216
def start(self):
217+
should_stop = self._control_channel.should_agent_stop()
218+
if should_stop:
219+
logger.info("The Monkey Island has instructed this agent to stop")
220+
return
221+
217222
self._setup_agent_event_forwarder()
218223
self._agent_event_forwarder.start()
219224
self._plugin_event_forwarder.start()
220225

221226
logger.info("Agent is starting...")
222227

223-
should_stop = self._control_channel.should_agent_stop()
224-
if should_stop:
225-
logger.info("The Monkey Island has instructed this agent to stop")
226-
return
227-
228228
operating_system = self._discover_os()
229229
self._discover_hostname()
230230

0 commit comments

Comments
 (0)