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 Robustness of Agent Foreground and Background Execution Modes #288

Open
vikman90 opened this issue Nov 11, 2024 · 1 comment
Open
Assignees
Labels
level/task Task issue module/agent mvp Minimum Viable Product refinement type/enhancement Enhancement issue

Comments

@vikman90
Copy link
Member

vikman90 commented Nov 11, 2024

Parent Issue: #241

Description

The Wazuh agent currently has issues handling its execution modes when run with --run (foreground) or --start (background) flags. Specifically, launching the agent in foreground with ./wazuh-agent --run can sometimes print the following message:

wazuh-agent already running

This message typically indicates that an instance of the agent is already running. However, it may also appear if the agent's previous process terminated unexpectedly, which leads to unreliable behavior.

Proposed Solution

  1. Separate --run and --start behavior:
    • --run: Should only launch the agent in the foreground without checking if an instance is already running.
    • --start: Should launch the agent in the background and include checks to ensure no other instance of the agent is running.
  2. PID file handling:
    When using --start, the agent should:
    • Check for the existence of a PID file.
    • If a PID file exists, verify if it corresponds to a currently running agent process.
    • If no running process is found or the PID file does not exist, perform a fork and execute the agent in background mode (--run).
  3. Systemd Compatibility:
    • Ensure that the modified behavior aligns with Systemd’s service management for proper control over the agent's lifecycle.
@vikman90 vikman90 added level/task Task issue type/enhancement Enhancement issue module/agent mvp Minimum Viable Product refinement labels Nov 11, 2024
@sdvendramini
Copy link
Member

12/11/2024

I've started reproducing the problem and researching different approaches to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue module/agent mvp Minimum Viable Product refinement type/enhancement Enhancement issue
Projects
Status: In progress
Development

No branches or pull requests

2 participants