|
@@ -67,8 +67,15 @@ index.js (Entry Point)
|
|
|
- Exported as singleton
|
|
- Exported as singleton
|
|
|
|
|
|
|
|
**Logger (src/logger.js)**
|
|
**Logger (src/logger.js)**
|
|
|
-- Console-based logger with ANSI colors and timestamps
|
|
|
|
|
-- Methods: `info()`, `error()`, `webhook()`
|
|
|
|
|
|
|
+- Console and file-based logger with ANSI colors and timestamps
|
|
|
|
|
+- Methods: `info()`, `error()`, `webhook()`, `warn()`, `debug()`, `jobLifecycle()`
|
|
|
|
|
+- **File logging support** with automatic rotation:
|
|
|
|
|
+ - Enabled by default when running as systemd service
|
|
|
|
|
+ - Configurable via `FILE_LOGGING_ENABLED` environment variable
|
|
|
|
|
+ - Default log file: `/var/log/agent-manager.log`
|
|
|
|
|
+ - Automatic rotation when file reaches `MAX_LOG_SIZE` (default: 10MB)
|
|
|
|
|
+ - Keeps up to `MAX_LOG_FILES` rotated files (default: 5)
|
|
|
|
|
+ - ANSI color codes stripped from file output
|
|
|
- Exported as singleton
|
|
- Exported as singleton
|
|
|
|
|
|
|
|
**EmailNotifier (src/emailNotifier.js)**
|
|
**EmailNotifier (src/emailNotifier.js)**
|
|
@@ -134,6 +141,13 @@ sudo /bin/systemctl status agent-manager
|
|
|
sudo journalctl -u agent-manager -f
|
|
sudo journalctl -u agent-manager -f
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
+**View application log file:**
|
|
|
|
|
+```bash
|
|
|
|
|
+tail -f /var/log/agent-manager.log
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+**Debugging**: When running as a systemd service, file logging is enabled by default. All application logs (INFO, WARN, ERROR, DEBUG, webhook events, job lifecycle) are written to `/var/log/agent-manager.log`. The log file is automatically rotated when it reaches 10MB (default), keeping up to 5 rotated files. For troubleshooting issues, check this file for detailed execution logs.
|
|
|
|
|
+
|
|
|
**Note**: The `claude` user has passwordless sudo access to restart the agent-manager service via `/etc/sudoers.d/50-agent-manager` configuration.
|
|
**Note**: The `claude` user has passwordless sudo access to restart the agent-manager service via `/etc/sudoers.d/50-agent-manager` configuration.
|
|
|
|
|
|
|
|
**Testing endpoints:**
|
|
**Testing endpoints:**
|
|
@@ -170,6 +184,16 @@ WEBHOOK_{EVENT_TYPE}_ENABLED=true|false
|
|
|
|
|
|
|
|
**Supported Event Types:** push, pull_request, create, delete, release, issues, issue_comment, global
|
|
**Supported Event Types:** push, pull_request, create, delete, release, issues, issue_comment, global
|
|
|
|
|
|
|
|
|
|
+**File Logging Configuration:**
|
|
|
|
|
+```env
|
|
|
|
|
+FILE_LOGGING_ENABLED=true|false # Enable/disable file logging (default: false, auto-enabled for systemd)
|
|
|
|
|
+LOG_FILE_PATH=/var/log/agent-manager.log # Path to log file (default: /var/log/agent-manager.log)
|
|
|
|
|
+MAX_LOG_SIZE=10485760 # Max size in bytes before rotation (default: 10MB)
|
|
|
|
|
+MAX_LOG_FILES=5 # Number of rotated files to keep (default: 5)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+**Note**: File logging is **automatically enabled** when running as a systemd service. The logger detects systemd environment and enables file output by default. For debugging, check `/var/log/agent-manager.log`.
|
|
|
|
|
+
|
|
|
**MCP Server Configuration:**
|
|
**MCP Server Configuration:**
|
|
|
```env
|
|
```env
|
|
|
GOGS_MCP_PATH=/data/gogs-mcp/dist/index.js # Path to gogs-mcp server for headless Claude Code
|
|
GOGS_MCP_PATH=/data/gogs-mcp/dist/index.js # Path to gogs-mcp server for headless Claude Code
|
|
@@ -239,6 +263,7 @@ Copy from `commands.json.example` and configure commands for each event type.
|
|
|
9. **Multiple Commands**: Each event type can have multiple commands that execute sequentially
|
|
9. **Multiple Commands**: Each event type can have multiple commands that execute sequentially
|
|
|
10. **Shell & Node Execution**: Commands can be shell scripts or Node.js scripts
|
|
10. **Shell & Node Execution**: Commands can be shell scripts or Node.js scripts
|
|
|
11. **Email Notifications**: Optional callback-based email notifications with condition matching
|
|
11. **Email Notifications**: Optional callback-based email notifications with condition matching
|
|
|
|
|
+12. **File Logging**: Automatic file logging with rotation (enabled by default for systemd services)
|
|
|
|
|
|
|
|
## Extending with Callbacks
|
|
## Extending with Callbacks
|
|
|
|
|
|