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

Improve agent execution modes #313

Merged
merged 7 commits into from
Nov 22, 2024

Conversation

sdvendramini
Copy link
Member

@sdvendramini sdvendramini commented Nov 19, 2024

Related issue
#288

This PR aims to improve how the agent runs in different environments.

The --start and --run options have been removed, so the agent now starts running by default without any options. Additionally, the --stop and --restart options have also been removed, but currently only on Unix systems.

The creation of the wazuh-agent.pid file has been replaced with the creation of a wazuh-agent.lock file. When the file is created, a write lock is applied, lasting until the execution ends. This prevents the execution of a new instance without needing to check the PID or process name.

For now, the lock file will be created in the execution directory under var/run.

@sdvendramini sdvendramini self-assigned this Nov 19, 2024
@sdvendramini sdvendramini force-pushed the enhancement/288-improve-agent-execution-modes branch 6 times, most recently from d0aafd4 to 6c42847 Compare November 20, 2024 16:52
Copy link
Member

@TomasTurina TomasTurina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to update the BUILD.md file.

src/agent/src/process_options_unix.cpp Show resolved Hide resolved
src/agent/src/process_options_unix.cpp Outdated Show resolved Hide resolved
src/agent/src/process_options_unix.cpp Outdated Show resolved Hide resolved
src/agent/src/main.cpp Show resolved Hide resolved
src/agent/src/unix_daemon.cpp Outdated Show resolved Hide resolved
@sdvendramini sdvendramini force-pushed the enhancement/288-improve-agent-execution-modes branch 2 times, most recently from dbef125 to 0ba59bc Compare November 22, 2024 10:45
@sdvendramini sdvendramini marked this pull request as ready for review November 22, 2024 12:07
@sdvendramini sdvendramini force-pushed the enhancement/288-improve-agent-execution-modes branch 4 times, most recently from 7aec7db to aea31b7 Compare November 22, 2024 15:01
The way the agent is executed has been simplified. Additionally, the use of a
PID file to check if the agent is running has been replaced with a
wazuh-agent.lock file, which remains write-locked during the agent's execution.
This prevents another instance from running. The `--start` and `--run` options
have been removed, and the process now runs in the foreground without any
options. The `--stop` and `--restart` options have also been removed.
The GetExecutablePath function has been modified to support macOS.
Changes were made to correctly generate RPM and DEB packages with the new
execution modes.
The BUILD.md file has been updated to reflect the new behavior.
Validation of execution options has been added.
@sdvendramini sdvendramini force-pushed the enhancement/288-improve-agent-execution-modes branch from aea31b7 to 694389a Compare November 22, 2024 15:57
@TomasTurina TomasTurina merged commit e3e7179 into master Nov 22, 2024
5 checks passed
@TomasTurina TomasTurina deleted the enhancement/288-improve-agent-execution-modes branch November 22, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Robustness of Agent Foreground and Background Execution Modes
2 participants