Skip to content

Commit 3e2d951

Browse files
ambledclaude
andcommitted
Add antctl debug mode configuration (v0.3.26)
- Added --antctl_debug option for antctl process manager - Environment variable: ANTCTL_DEBUG - Enables debug output for all antctl commands by adding --debug flag - Automatically enabled when WNM logging level is set to DEBUG - Added antctl_debug field to Machine model (boolean/integer) - Updated AntctlManager to check debug mode during initialization - Updated configuration system for persistent and temporary debug mode - Added comprehensive documentation to USER-GUIDE-PART3.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7f3cba3 commit 3e2d951

6 files changed

Lines changed: 117 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
## [Unreleased]
44

5+
## [0.3.26] - 2025-12-28
6+
7+
### Added
8+
- **Antctl debug mode configuration**: Added `--antctl_debug` option for antctl process manager
9+
- Environment variable: `ANTCTL_DEBUG`
10+
- Default: `False` (automatically enabled when `--loglevel DEBUG` is set)
11+
- Enables debug output for all antctl commands by adding `--debug` flag to antctl invocations
12+
- Automatically enabled when WNM logging level is set to DEBUG
13+
- Use cases: Troubleshooting antctl issues, debugging node management problems, development and testing
14+
- Only affects `antctl+user` and `antctl+sudo` process managers
15+
- Added to Machine model with database field `antctl_debug` (boolean/integer)
16+
- Added command-line option and configuration system support
17+
- Updated AntctlManager to check debug mode during initialization and add `--debug` to command
18+
- Debug mode can be enabled persistently (updates database) or temporarily via command-line
19+
- Documentation added to USER-GUIDE-PART3.md with comprehensive usage examples
20+
- Examples:
21+
- Via flag: `wnm --antctl_debug`
22+
- Via env: `export ANTCTL_DEBUG=1; wnm`
23+
- Auto with debug logging: `wnm --loglevel DEBUG`
24+
- Persistent: `wnm --force_action update_config --antctl_debug`
25+
526
## [0.3.25] - 2025-12-16
627

728
### Added

docs/USER-GUIDE-PART3.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,62 @@ No user configuration is currently needed.
606606
- `--antctl_path /usr/local/bin/antctl`
607607
- `--antctl_path /opt/homebrew/bin/antctl` (Homebrew on Apple Silicon)
608608

609+
### Antctl Debug Mode
610+
611+
**`--antctl_debug`**
612+
- Environment variable: `ANTCTL_DEBUG`
613+
- Type: Boolean flag
614+
- Default: `False` (automatically enabled when `--loglevel DEBUG` is set)
615+
- Description: Enable debug output for antctl commands by adding `--debug` flag to all antctl invocations
616+
- Use cases:
617+
- **Troubleshooting antctl issues**: Get detailed output from antctl operations
618+
- **Debugging node management problems**: See verbose antctl command execution
619+
- **Understanding antctl behavior**: View internal antctl decision-making
620+
- **Development and testing**: Monitor antctl operations in detail
621+
- Notes:
622+
- Only affects `antctl+user` and `antctl+sudo` process managers
623+
- Automatically enabled when WNM logging level is set to DEBUG
624+
- When enabled, all antctl commands run with `--debug` flag (e.g., `antctl --debug start`, `antctl --debug add`)
625+
- Debug output from antctl appears in WNM logs
626+
- Can be enabled persistently in database or temporarily via command-line
627+
- Examples:
628+
629+
**Enable debug mode for all antctl operations:**
630+
```bash
631+
# Via command-line flag
632+
wnm --antctl_debug
633+
634+
# Via environment variable
635+
export ANTCTL_DEBUG=1
636+
wnm
637+
638+
# Automatically enabled with DEBUG logging
639+
wnm --loglevel DEBUG
640+
```
641+
642+
**Persistent debug configuration:**
643+
```bash
644+
# Enable for all future runs (updates database)
645+
wnm --force_action update_config --antctl_debug
646+
647+
# Or add to config file
648+
echo "antctl_debug=True" >> ~/.local/share/wnm/config
649+
```
650+
651+
**Temporary debug session:**
652+
```bash
653+
# Debug a specific operation
654+
wnm --antctl_debug --force_action add --count 1
655+
```
656+
657+
**Disable debug mode:**
658+
```bash
659+
# Debug mode stays enabled once set in database
660+
# To disable, you must explicitly turn it off
661+
# Setting the environment varialbe to false should persist
662+
ANTCTL_DEBUG=false
663+
```
664+
609665
### Process Manager Selection
610666

611667
**`--process_manager`**

src/wnm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""A service to manage a cluster of decentralized Autonomi nodes"""
22

3-
__version__ = "0.3.25"
3+
__version__ = "0.3.26"

src/wnm/config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ def load_config():
542542
env_var="ANTCTL_PATH",
543543
help="Path to the antctl binary (default: ~/.local/bin/antctl)",
544544
)
545+
c.add(
546+
"--antctl_debug",
547+
env_var="ANTCTL_DEBUG",
548+
help="Enable debug output for antctl commands (also enabled when --loglevel DEBUG is set)",
549+
action="store_true",
550+
)
545551

546552
options = c.parse_known_args()[0] or []
547553

@@ -755,6 +761,11 @@ def merge_config_changes(options, machine_config):
755761
# Only update antctl_path if explicitly provided (not None)
756762
if options.antctl_path and options.antctl_path != machine_config.antctl_path:
757763
cfg["antctl_path"] = options.antctl_path
764+
# Only update antctl_debug if explicitly provided (check if in command line or env var)
765+
# Don't update based on store_true default value of False
766+
if "--antctl_debug" in sys.argv or "--antctl-debug" in sys.argv or os.getenv("ANTCTL_DEBUG"):
767+
if bool(options.antctl_debug) != bool(machine_config.antctl_debug):
768+
cfg["antctl_debug"] = bool(options.antctl_debug)
758769

759770
return cfg
760771

@@ -906,6 +917,9 @@ def load_anm_config(options):
906917
_get_option(options, "antctl_path") or "~/.local/bin/antctl"
907918
)
908919

920+
# antctl debug mode (defaults to False)
921+
anm_config["antctl_debug"] = bool(_get_option(options, "antctl_debug", False))
922+
909923
return anm_config
910924

911925

@@ -1012,6 +1026,7 @@ def define_machine(options):
10121026
"no_upnp": bool(_get_option(options, "no_upnp", False)),
10131027
"antnode_path": _get_option(options, "antnode_path") or "~/.local/bin/antnode",
10141028
"antctl_path": _get_option(options, "antctl_path") or "~/.local/bin/antctl",
1029+
"antctl_debug": bool(_get_option(options, "antctl_debug", False)),
10151030
}
10161031

10171032
# Set default process manager based on platform if not specified

src/wnm/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ class Machine(Base):
121121
antctl_path: Mapped[Optional[str]] = mapped_column(
122122
UnicodeText, default="~/.local/bin/antctl"
123123
)
124+
antctl_debug: Mapped[bool] = mapped_column(
125+
Integer, default=0
126+
) # SQLite uses 0/1 for boolean
124127

125128
# Relationships
126129
containers: Mapped[list["Container"]] = relationship(
@@ -177,6 +180,7 @@ def __init__(
177180
no_upnp=True,
178181
antnode_path="~/.local/bin/antnode",
179182
antctl_path="~/.local/bin/antctl",
183+
antctl_debug=False,
180184
survey_delay=0,
181185
action_delay=0,
182186
):
@@ -227,6 +231,7 @@ def __init__(
227231
self.no_upnp = no_upnp
228232
self.antnode_path = antnode_path
229233
self.antctl_path = antctl_path
234+
self.antctl_debug = antctl_debug
230235

231236
def __repr__(self):
232237
return (

src/wnm/process_managers/antctl_manager.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ def __init__(
7373
else:
7474
self.antctl_cmd = [antctl_path]
7575

76+
# Check if we should enable debug mode
77+
# Debug is enabled if either:
78+
# 1. antctl_debug flag is set in machine config
79+
# 2. Current logging level is DEBUG
80+
debug_mode = False
81+
82+
# Check machine config for antctl_debug setting
83+
if machine_config and hasattr(machine_config, 'antctl_debug') and machine_config.antctl_debug:
84+
debug_mode = True
85+
86+
# Also enable debug mode if logging level is DEBUG
87+
if logging.getLogger().getEffectiveLevel() == logging.DEBUG:
88+
debug_mode = True
89+
90+
# Add --debug flag to command if debug mode is enabled
91+
if debug_mode:
92+
self.antctl_cmd.append("--debug")
93+
logging.debug("AntctlManager: Debug mode enabled for antctl commands")
94+
7695
def _run_antctl(
7796
self, args: list, capture_output: bool = True
7897
) -> subprocess.CompletedProcess:

0 commit comments

Comments
 (0)