Skip to content

Commit 2b5387d

Browse files
committed
refactor: update command references and remove updater functionality
1 parent dd31d70 commit 2b5387d

File tree

8 files changed

+30
-816
lines changed

8 files changed

+30
-816
lines changed

CLAUDE.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,18 @@ The agent uses [Cobra](https://github.com/spf13/cobra) for CLI command handling:
5555

5656
- **cmd/root.go**: Base command that all subcommands attach to
5757
- **cmd/start.go**: Start command with three modes:
58-
- Foreground mode (`pulse start`): Runs in terminal, blocks execution
59-
- Daemon mode (`pulse start -d`): Spawns background process using `exec.Command` with `Setsid: true`
58+
- Foreground mode (`nodepulse start`): Runs in terminal, blocks execution
59+
- Daemon mode (`nodepulse start -d`): Spawns background process using `exec.Command` with `Setsid: true`
6060
- Both modes create PID file EXCEPT when running under systemd (detected via `INVOCATION_ID` env var)
6161
- **Current**: Scrapes Prometheus instead of collecting custom metrics
6262
- **cmd/stop.go**: Stops daemon mode only (reads PID file, sends SIGTERM → SIGKILL if needed)
6363
- Will NOT stop systemd-managed processes (they don't create PID files)
6464
- Provides helpful message if systemd service is running
6565
- **cmd/service.go**: systemd service management (install/start/stop/restart/status/uninstall)
66-
- **cmd/setup.go**: Setup wizard for first-time configuration (command: `pulse setup`)
66+
- **cmd/setup.go**: Setup wizard for first-time configuration (command: `nodepulse setup`)
6767
- **Current**: Interactive TUI mode removed, only quick mode (`--yes`) available
6868
- Prompts for: endpoint URL and server_id
6969
- **cmd/status.go**: Shows comprehensive agent status including server ID, config, service status, buffer state, and logs
70-
- **cmd/update.go**: Self-update command that checks for new versions and performs updates
7170

7271
### Prometheus Scraping (internal/prometheus/)
7372
The agent scrapes Prometheus exporters instead of collecting custom metrics:
@@ -108,13 +107,13 @@ Uses [Viper](https://github.com/spf13/viper) for config loading from YAML:
108107
- Default endpoint: `/metrics/prometheus`
109108
- **serverid.go**: Server ID generation and persistence
110109
- Auto-generates UUID if not set in config
111-
- Persists to `/var/lib/node-pulse/server_id`
110+
- Persists to `/var/lib/nodepulse/server_id`
112111
- Validates format: alphanumeric + dashes, must start/end with alphanumeric
113112

114113
Config search paths (in order):
115114
1. Explicit `--config` flag
116-
2. `/etc/node-pulse/nodepulse.yml`
117-
3. `$HOME/.node-pulse/nodepulse.yml`
115+
2. `/etc/nodepulse/nodepulse.yml`
116+
3. `$HOME/.nodepulse/nodepulse.yml`
118117
4. `./nodepulse.yml`
119118

120119
### Logger (internal/logger/)
@@ -124,21 +123,18 @@ Structured logging with [Zap](https://github.com/uber-go/zap):
124123
- File rotation with [Lumberjack](https://github.com/natefinch/lumberjack)
125124
- Configurable log level, size limits, and retention
126125

127-
### Updater (internal/updater/)
128-
Self-update system for the agent:
126+
### Update Management
127+
**Agent updates are managed centrally via Ansible**, not by the agent itself:
129128

130-
- **updater.go**: Core updater logic
131-
- Checks version API endpoint for new releases
132-
- Downloads new binary with SHA256 checksum verification
133-
- Atomically replaces `/usr/local/bin/pulse`
134-
- Restarts agent service via systemd
135-
- Includes automatic rollback on failure
136-
- **Version endpoint**: `GET /agent/version?version={current}&os={os}&arch={arch}`
129+
- Updates deployed through dashboard's Ansible deployment system
130+
- Version controlled with rollback capability
131+
- Staged rollouts across server fleet
132+
- No self-update mechanism in the agent (removed in v0.1.x)
137133

138134
### PID File Management (internal/pidfile/)
139135
Handles process tracking and prevents duplicate agent runs:
140136

141-
- **Location**: `/var/run/pulse.pid` (root) or `~/.node-pulse/pulse.pid` (user)
137+
- **Location**: `/var/run/nodepulse.pid` (root) or `~/.nodepulse/nodepulse.pid` (user)
142138
- **Stale PID detection**: `CheckRunning()` automatically detects and cleans stale PID files
143139
- **Systemd detection**: Checks for `INVOCATION_ID` environment variable (no PID file created under systemd)
144140

@@ -176,8 +172,9 @@ The agent runs as a **long-running daemon**:
176172
- **Dependencies**: `node_exporter` must be installed and running
177173
- **Security**: Port 9100 must be blocked from external access (UFW/iptables)
178174
- **Permissions**:
179-
- Regular user can run `pulse start`, `pulse start -d`, `pulse stop`
180-
- Root required for `pulse service`, `pulse setup`, and `pulse update` commands
175+
- Regular user can run `nodepulse start`, `nodepulse start -d`, `nodepulse stop`
176+
- Root required for `nodepulse service` and `nodepulse setup` commands
177+
- **Deployment**: Managed via Ansible from central dashboard (not manual installation)
181178

182179
## Testing Notes
183180

@@ -207,7 +204,7 @@ To test the full flow locally:
207204

208205
4. Verify buffering by pointing endpoint to invalid URL and checking buffer directory:
209206
```bash
210-
ls -la /var/lib/node-pulse/buffer/
207+
ls -la /var/lib/nodepulse/buffer/
211208
```
212209

213210
## Release Process

INSTALLATION.md

Lines changed: 0 additions & 212 deletions
This file was deleted.

cmd/service.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"path/filepath"
88

99
"github.com/node-pulse/agent/internal/config"
10-
"github.com/node-pulse/agent/internal/installer"
1110
"github.com/node-pulse/agent/internal/pidfile"
1211
"github.com/spf13/cobra"
1312
)
@@ -129,29 +128,7 @@ func installService(cmd *cobra.Command, args []string) error {
129128
return fmt.Errorf("failed to enable service: %w", err)
130129
}
131130

132-
// Install updater timer
133-
fmt.Println("Installing updater timer...")
134-
if err := installer.InstallTimer(); err != nil {
135-
return fmt.Errorf("failed to install updater timer: %w", err)
136-
}
137-
138-
// Reload systemd (for timer units)
139-
if err := runSystemctl("daemon-reload"); err != nil {
140-
return fmt.Errorf("failed to reload systemd: %w", err)
141-
}
142-
143-
// Enable updater timer
144-
if err := runSystemctl("enable", "node-pulse-updater.timer"); err != nil {
145-
return fmt.Errorf("failed to enable updater timer: %w", err)
146-
}
147-
148-
// Start updater timer
149-
if err := runSystemctl("start", "node-pulse-updater.timer"); err != nil {
150-
return fmt.Errorf("failed to start updater timer: %w", err)
151-
}
152-
153131
fmt.Println("Service installed and enabled successfully!")
154-
fmt.Println("Updater timer installed and started (checks for updates every 10 minutes)")
155132
fmt.Println("\nTo start the service, run:")
156133
fmt.Printf(" sudo pulse service start\n")
157134
return nil
@@ -239,22 +216,12 @@ func uninstallService(cmd *cobra.Command, args []string) error {
239216
return fmt.Errorf("failed to remove service file: %w", err)
240217
}
241218

242-
// Stop and disable updater timer
243-
fmt.Println("Uninstalling updater timer...")
244-
runSystemctl("stop", "node-pulse-updater.timer")
245-
runSystemctl("disable", "node-pulse-updater.timer")
246-
247-
// Remove timer units
248-
if err := installer.UninstallTimer(); err != nil {
249-
fmt.Printf("Warning: failed to uninstall timer: %v\n", err)
250-
}
251-
252219
// Reload systemd
253220
if err := runSystemctl("daemon-reload"); err != nil {
254221
return fmt.Errorf("failed to reload systemd: %w", err)
255222
}
256223

257-
fmt.Println("Service and updater timer uninstalled successfully!")
224+
fmt.Println("Service uninstalled successfully!")
258225
return nil
259226
}
260227

0 commit comments

Comments
 (0)