wnm 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. wnm-0.1.5/MANIFEST.in +2 -0
  2. wnm-0.1.5/PKG-INFO +367 -0
  3. wnm-0.1.5/README.md +328 -0
  4. wnm-0.1.5/alembic/env.py +89 -0
  5. wnm-0.1.5/alembic/script.py.mako +28 -0
  6. wnm-0.1.5/alembic/versions/3249fcc20390_add_delay_restart_to_machine.py +39 -0
  7. wnm-0.1.5/alembic/versions/44f23f078686_add_antnode_path_to_machine.py +42 -0
  8. wnm-0.1.5/alembic/versions/62bd2784638c_add_log_dir_to_node.py +34 -0
  9. wnm-0.1.5/alembic/versions/7c5a573319da_add_rpc_port_start_to_machine.py +39 -0
  10. wnm-0.1.5/alembic/versions/abc5afa09a61_add_no_upnp_to_machine.py +34 -0
  11. wnm-0.1.5/alembic/versions/ade8fcd1fc9a_add_influx_metrics_to_node.py +76 -0
  12. wnm-0.1.5/alembic/versions/eeec2af7114c_baseline_nov_6_2025_schema.py +38 -0
  13. wnm-0.1.5/alembic.ini +148 -0
  14. wnm-0.1.5/pyproject.toml +57 -0
  15. wnm-0.1.5/requirements-dev.txt +10 -0
  16. wnm-0.1.5/requirements.txt +8 -0
  17. wnm-0.1.5/setup.cfg +4 -0
  18. wnm-0.1.5/src/wnm/__init__.py +3 -0
  19. wnm-0.1.5/src/wnm/__main__.py +350 -0
  20. wnm-0.1.5/src/wnm/actions.py +45 -0
  21. wnm-0.1.5/src/wnm/common.py +24 -0
  22. wnm-0.1.5/src/wnm/config.py +1020 -0
  23. wnm-0.1.5/src/wnm/db_migration.py +266 -0
  24. wnm-0.1.5/src/wnm/decision_engine.py +388 -0
  25. wnm-0.1.5/src/wnm/executor.py +1382 -0
  26. wnm-0.1.5/src/wnm/firewall/__init__.py +13 -0
  27. wnm-0.1.5/src/wnm/firewall/base.py +71 -0
  28. wnm-0.1.5/src/wnm/firewall/factory.py +95 -0
  29. wnm-0.1.5/src/wnm/firewall/null_firewall.py +71 -0
  30. wnm-0.1.5/src/wnm/firewall/ufw_manager.py +118 -0
  31. wnm-0.1.5/src/wnm/migration.py +162 -0
  32. wnm-0.1.5/src/wnm/models.py +556 -0
  33. wnm-0.1.5/src/wnm/process_managers/__init__.py +23 -0
  34. wnm-0.1.5/src/wnm/process_managers/antctl_manager.py +533 -0
  35. wnm-0.1.5/src/wnm/process_managers/base.py +205 -0
  36. wnm-0.1.5/src/wnm/process_managers/docker_manager.py +373 -0
  37. wnm-0.1.5/src/wnm/process_managers/factory.py +94 -0
  38. wnm-0.1.5/src/wnm/process_managers/launchd_manager.py +640 -0
  39. wnm-0.1.5/src/wnm/process_managers/setsid_manager.py +369 -0
  40. wnm-0.1.5/src/wnm/process_managers/systemd_manager.py +584 -0
  41. wnm-0.1.5/src/wnm/reports.py +408 -0
  42. wnm-0.1.5/src/wnm/utils.py +489 -0
  43. wnm-0.1.5/src/wnm/wallets.py +177 -0
  44. wnm-0.1.5/src/wnm.egg-info/PKG-INFO +367 -0
  45. wnm-0.1.5/src/wnm.egg-info/SOURCES.txt +57 -0
  46. wnm-0.1.5/src/wnm.egg-info/dependency_links.txt +1 -0
  47. wnm-0.1.5/src/wnm.egg-info/entry_points.txt +2 -0
  48. wnm-0.1.5/src/wnm.egg-info/requires.txt +20 -0
  49. wnm-0.1.5/src/wnm.egg-info/top_level.txt +1 -0
  50. wnm-0.1.5/tests/test_config.py +346 -0
  51. wnm-0.1.5/tests/test_decision_engine.py +557 -0
  52. wnm-0.1.5/tests/test_firewall.py +356 -0
  53. wnm-0.1.5/tests/test_forced_actions.py +1071 -0
  54. wnm-0.1.5/tests/test_macos_native.py +122 -0
  55. wnm-0.1.5/tests/test_models.py +172 -0
  56. wnm-0.1.5/tests/test_process_managers.py +720 -0
  57. wnm-0.1.5/tests/test_reports.py +400 -0
  58. wnm-0.1.5/tests/test_system_metrics.py +304 -0
  59. wnm-0.1.5/tests/test_wallets.py +268 -0
wnm-0.1.5/MANIFEST.in ADDED
@@ -0,0 +1,2 @@
1
+ include alembic.ini
2
+ recursive-include alembic *.py *.mako
wnm-0.1.5/PKG-INFO ADDED
@@ -0,0 +1,367 @@
1
+ Metadata-Version: 2.4
2
+ Name: wnm
3
+ Version: 0.1.5
4
+ Summary: Manager for Autonomi nodes
5
+ Author-email: Troy Johnson <troy@weave.sh>
6
+ License: GPL-3.0
7
+ Project-URL: Repository, https://github.com/iweave/weave-node-manager.git
8
+ Project-URL: Issues, https://github.com/iweave/weave-node-manager/issues
9
+ Keywords: Autonomi,antnode,weave,xd7
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Topic :: System :: Distributed Computing
18
+ Requires-Python: >=3.12.3
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: python-dotenv
21
+ Requires-Dist: requests
22
+ Requires-Dist: packaging
23
+ Requires-Dist: sqlalchemy
24
+ Requires-Dist: alembic
25
+ Requires-Dist: json-fix
26
+ Requires-Dist: psutil
27
+ Requires-Dist: configargparse
28
+ Provides-Extra: dev
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: isort; extra == "dev"
31
+ Requires-Dist: build; extra == "dev"
32
+ Requires-Dist: twine; extra == "dev"
33
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
36
+ Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
37
+ Requires-Dist: pytest-docker>=3.1.0; extra == "dev"
38
+ Requires-Dist: docker>=7.0.0; extra == "dev"
39
+
40
+ # Weave Node Manager
41
+
42
+ ## Overview
43
+ Weave Node Manager (wnm) is a Python application designed to manage Autonomi nodes on Linux and macOS systems.
44
+
45
+ **Platforms**:
46
+ - **Linux**: systemd or setsid for process management, UFW for firewall
47
+ - **macOS**: launchd for process management (native support)
48
+ - **Python 3.12.3+** required
49
+
50
+ ## Features
51
+ - Automatic node lifecycle management (create, start, stop, upgrade, remove)
52
+ - Resource-based decision engine (CPU, memory, disk, I/O, load average thresholds)
53
+ - Platform-specific process management (systemd on Linux, launchd on macOS)
54
+ - Per-node binary copies for independent upgrades
55
+ - SQLite database for configuration and state tracking
56
+ - Support for configuration via environment variables, config files, or command-line parameters
57
+
58
+ ## Warning - Alpha Software
59
+
60
+ This code is Alpha. On Linux, it can migrate from an existing [anm](https://github.com/safenetforum-community/NTracking/tree/main/anm) installation. On macOS, it provides native development and testing support using launchd.
61
+
62
+ ## Installation
63
+
64
+ ### macOS (Development & Testing)
65
+
66
+ macOS support uses launchd for process management and is ideal for development and testing.
67
+
68
+ #### 1. Install antup (Autonomi binary manager)
69
+ ```bash
70
+ curl -sSL https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | bash
71
+ ```
72
+
73
+ #### 2. Download antnode binary
74
+ ```bash
75
+ ~/.local/bin/antup node
76
+ ```
77
+
78
+ #### 3. Install WNM from PyPI
79
+ ```bash
80
+ pip3 install wnm
81
+ ```
82
+
83
+ #### 4. Or install from source
84
+ ```bash
85
+ git clone https://github.com/iweave/weave-node-manager.git
86
+ cd weave-node-manager
87
+ pip3 install -e .
88
+ ```
89
+
90
+ #### 5. Initialize and configure
91
+ ```bash
92
+ # Initialize with your rewards address
93
+ wnm --init --rewards_address 0xYourEthereumAddress
94
+
95
+ # Run in dry-run mode to test
96
+ wnm --dry_run
97
+
98
+ # Or run normally to start managing nodes
99
+ wnm
100
+ ```
101
+
102
+ #### 6. Optional: Add to cron for automatic management
103
+ ```bash
104
+ # Add to crontab (runs every minute)
105
+ crontab -e
106
+
107
+ # Add this line:
108
+ */1 * * * * /usr/local/bin/wnm >> ~/Library/Logs/autonomi/wnm-cron.log 2>&1
109
+ ```
110
+
111
+ **macOS Notes:**
112
+ - Uses `~/Library/Application Support/autonomi/node/` for data
113
+ - Uses `~/Library/Logs/autonomi/` for logs
114
+ - Nodes managed via launchd (`~/Library/LaunchAgents/`)
115
+ - No root/sudo access required
116
+
117
+ ### Linux (User-Level, Recommended)
118
+
119
+ Non-root installation using setsid for process management.
120
+
121
+ #### 1. Install antup (Autonomi binary manager)
122
+ ```bash
123
+ curl -sSL https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | bash
124
+ ```
125
+
126
+ #### 2. Download antnode binary
127
+ ```bash
128
+ ~/.local/bin/antup node
129
+ ```
130
+
131
+ #### 3. Install WNM from PyPI
132
+ ```bash
133
+ pip3 install wnm
134
+ ```
135
+
136
+ #### 4. Or install from source
137
+ ```bash
138
+ git clone https://github.com/iweave/weave-node-manager.git
139
+ cd weave-node-manager
140
+ pip3 install -e .
141
+ ```
142
+
143
+ #### 5. Initialize and configure
144
+ ```bash
145
+ # Initialize with your rewards address
146
+ wnm --init --rewards_address 0xYourEthereumAddress
147
+
148
+ # Run in dry-run mode to test
149
+ wnm --dry_run
150
+
151
+ # Or run normally
152
+ wnm
153
+ ```
154
+
155
+ #### 6. Optional: Add to cron
156
+ ```bash
157
+ crontab -e
158
+
159
+ # Add this line:
160
+ */1 * * * * ~/.local/bin/wnm >> ~/.local/share/autonomi/logs/wnm-cron.log 2>&1
161
+ ```
162
+
163
+ **Linux User-Level Notes:**
164
+ - Uses `~/.local/share/autonomi/node/` for data (XDG spec)
165
+ - Uses `~/.local/share/autonomi/logs/` for logs
166
+ - Nodes run as background processes (setsid)
167
+ - No root/sudo required
168
+
169
+ ### Linux (Root-Level, Production)
170
+
171
+ Root installation using systemd for process management.
172
+
173
+ #### 1. Install system dependencies
174
+ ```bash
175
+ sudo apt install -y python3.12-venv python3-pip
176
+ ```
177
+
178
+ #### 2. Install antup and antnode
179
+ ```bash
180
+ curl -sSL https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | bash
181
+ ~/.local/bin/antup node
182
+ sudo cp ~/.local/bin/antnode /usr/local/bin/
183
+ ```
184
+
185
+ #### 3. Install WNM
186
+ ```bash
187
+ sudo pip3 install wnm
188
+ ```
189
+
190
+ #### 4. Initialize as root
191
+ ```bash
192
+ # Migrate from existing anm installation
193
+ sudo wnm --init --migrate_anm
194
+
195
+ # Or initialize fresh
196
+ sudo wnm --init --rewards_address 0xYourEthereumAddress
197
+ ```
198
+
199
+ #### 5. Add to cron
200
+ ```bash
201
+ sudo crontab -e
202
+
203
+ # Add this line:
204
+ */1 * * * * /usr/local/bin/wnm >> /var/log/antnode/wnm-cron.log 2>&1
205
+ ```
206
+
207
+ **Linux Root-Level Notes:**
208
+ - Uses `/var/antctl/` for data (legacy anm compatibility)
209
+ - Uses `/var/log/antnode/` for logs
210
+ - Nodes managed via systemd (`/etc/systemd/system/`)
211
+ - Requires root/sudo access
212
+ - Supports migration from anm
213
+
214
+ ## Configuration
215
+
216
+ Configuration follows a multi-layer priority system (highest to lowest):
217
+
218
+ 1. **Command-line arguments**: `wnm --cpu_less_than 70 --node_cap 50`
219
+ 2. **Environment variables**: Set in `.env` file or shell
220
+ 3. **Config files**:
221
+ - macOS: `~/Library/Application Support/autonomi/config`
222
+ - Linux (user): `~/.local/share/autonomi/config`
223
+ - Linux (root): `/var/antctl/config`
224
+ 4. **Database-stored config**: Persisted in `colony.db` after initialization
225
+ 5. **Default values**: Built-in defaults
226
+
227
+ ### Key Configuration Parameters
228
+
229
+ Resource thresholds control when nodes are added or removed:
230
+
231
+ - `--cpu_less_than` / `--cpu_remove`: CPU percentage thresholds (default: 70% / 80%)
232
+ - `--mem_less_than` / `--mem_remove`: Memory percentage thresholds (default: 70% / 80%)
233
+ - `--hd_less_than` / `--hd_remove`: Disk usage percentage thresholds (default: 70% / 80%)
234
+ - `--desired_load_average` / `--max_load_average_allowed`: Load average thresholds
235
+ - `--node_cap`: Maximum number of nodes (default: 50)
236
+ - `--rewards_address`: Wallet address(es) for node rewards (required) - see Wallet Configuration below
237
+ - `--node_storage`: Root directory for node data (auto-detected per platform)
238
+
239
+ ### Wallet Configuration
240
+
241
+ The `--rewards_address` parameter supports multiple formats for flexible reward distribution:
242
+
243
+ #### Single Wallet
244
+ Use a single Ethereum address or named wallet:
245
+ ```bash
246
+ # Ethereum address
247
+ wnm --init --rewards_address 0xYourEthereumAddress
248
+
249
+ # Named wallet: "donate" (uses your custom donate_address or the community foucet if not deefined)
250
+ wnm --init --rewards_address donate
251
+
252
+ # Named wallet: "faucet" (always uses the autonomi community faucet address)
253
+ wnm --init --rewards_address faucet
254
+ ```
255
+
256
+ #### Weighted Distribution
257
+ Distribute rewards across multiple wallets using weighted random selection:
258
+ ```bash
259
+ # Format: wallet1:weight1,wallet2:weight2,...
260
+ wnm --init --rewards_address "0xYourAddress:100,faucet:1,donate:10"
261
+ ```
262
+
263
+ In this example:
264
+ - Your address receives ~90% of nodes (100 out of 111 weight)
265
+ - Faucet receives ~1% of nodes (1 out of 111 weight)
266
+ - Donate address receives ~9% of nodes (10 out of 111 weight)
267
+
268
+ **Key Features:**
269
+ - **Random per node**: Each new node randomly selects a wallet based on weights
270
+ - **Named wallets**: Use `faucet` (project faucet) or `donate` (your custom donation address)
271
+ - **Case-insensitive**: `faucet`, `FAUCET`, and `Faucet` all work
272
+ - **Mix addresses and names**: Combine Ethereum addresses with named wallets
273
+ - **Changeable**: Update `--rewards_address` anytime to change distribution for new nodes
274
+
275
+ **Examples:**
276
+ ```bash
277
+ # 50/50 split between your address and faucet
278
+ wnm --rewards_address "0xYourAddress:1,faucet:1"
279
+
280
+ # Your address only
281
+ wnm --rewards_address 0xYourAddress
282
+
283
+ # Mostly yours, small donation to faucet
284
+ wnm --rewards_address "0xYourAddress:99,faucet:1"
285
+
286
+ # Multiple addresses with custom weights
287
+ wnm --rewards_address "0xAddress1:100,0xAddress2:50,faucet:10"
288
+ ```
289
+
290
+ ### anm Migration (Linux Only)
291
+
292
+ Upon finding an existing [anm](https://github.com/safenetforum-community/NTracking/tree/main/anm) installation, wnm will:
293
+ 1. Disable anm by removing `/etc/cron.d/anm`
294
+ 2. Import configuration from `/var/antctl/config`
295
+ 3. Discover and import existing nodes from systemd
296
+ 4. Take over management of the cluster
297
+
298
+ Use `wnm --init --migrate_anm` to trigger migration.
299
+
300
+ ## Usage
301
+
302
+ ### Run Once
303
+ ```bash
304
+ # macOS or Linux
305
+ wnm
306
+
307
+ # With dry-run (no actual changes)
308
+ wnm --dry_run
309
+
310
+ # Initialize first time
311
+ wnm --init --rewards_address 0xYourEthereumAddress
312
+ ```
313
+
314
+ ### Run via Cron (Recommended)
315
+
316
+ WNM is designed to run every minute via cron, making one decision per cycle:
317
+
318
+ **macOS:**
319
+ ```bash
320
+ crontab -e
321
+ # Add: */1 * * * * /usr/local/bin/wnm >> ~/Library/Logs/autonomi/wnm-cron.log 2>&1
322
+ ```
323
+
324
+ **Linux (user):**
325
+ ```bash
326
+ crontab -e
327
+ # Add: */1 * * * * ~/.local/bin/wnm >> ~/.local/share/autonomi/logs/wnm-cron.log 2>&1
328
+ ```
329
+
330
+ **Linux (root):**
331
+ ```bash
332
+ sudo crontab -e
333
+ # Add: */1 * * * * /usr/local/bin/wnm >> /var/log/antnode/wnm-cron.log 2>&1
334
+ ```
335
+
336
+ ### Development Mode
337
+
338
+ For development with live code reloading:
339
+
340
+ **macOS (native):**
341
+ ```bash
342
+ python3 -m wnm --dry_run
343
+ ```
344
+
345
+ **Linux (Docker):**
346
+ ```bash
347
+ ./scripts/dev.sh
348
+ # Inside container:
349
+ python3 -m wnm --dry_run
350
+ ```
351
+
352
+ See `DOCKER-DEV.md` for comprehensive Docker development workflow.
353
+
354
+ ## Platform Support
355
+
356
+ See `PLATFORM-SUPPORT.md` for detailed information about:
357
+ - Platform-specific process managers (systemd, launchd, setsid)
358
+ - Firewall management (UFW, null)
359
+ - Path conventions per platform
360
+ - Binary management and upgrades
361
+ - Testing strategies
362
+
363
+ ## Contributing
364
+ Contributions are welcome! Please submit a pull request or open an issue for any enhancements or bug fixes.
365
+
366
+ ## License
367
+ This project is licensed under the MIT License. See the LICENSE file for more details.
wnm-0.1.5/README.md ADDED
@@ -0,0 +1,328 @@
1
+ # Weave Node Manager
2
+
3
+ ## Overview
4
+ Weave Node Manager (wnm) is a Python application designed to manage Autonomi nodes on Linux and macOS systems.
5
+
6
+ **Platforms**:
7
+ - **Linux**: systemd or setsid for process management, UFW for firewall
8
+ - **macOS**: launchd for process management (native support)
9
+ - **Python 3.12.3+** required
10
+
11
+ ## Features
12
+ - Automatic node lifecycle management (create, start, stop, upgrade, remove)
13
+ - Resource-based decision engine (CPU, memory, disk, I/O, load average thresholds)
14
+ - Platform-specific process management (systemd on Linux, launchd on macOS)
15
+ - Per-node binary copies for independent upgrades
16
+ - SQLite database for configuration and state tracking
17
+ - Support for configuration via environment variables, config files, or command-line parameters
18
+
19
+ ## Warning - Alpha Software
20
+
21
+ This code is Alpha. On Linux, it can migrate from an existing [anm](https://github.com/safenetforum-community/NTracking/tree/main/anm) installation. On macOS, it provides native development and testing support using launchd.
22
+
23
+ ## Installation
24
+
25
+ ### macOS (Development & Testing)
26
+
27
+ macOS support uses launchd for process management and is ideal for development and testing.
28
+
29
+ #### 1. Install antup (Autonomi binary manager)
30
+ ```bash
31
+ curl -sSL https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | bash
32
+ ```
33
+
34
+ #### 2. Download antnode binary
35
+ ```bash
36
+ ~/.local/bin/antup node
37
+ ```
38
+
39
+ #### 3. Install WNM from PyPI
40
+ ```bash
41
+ pip3 install wnm
42
+ ```
43
+
44
+ #### 4. Or install from source
45
+ ```bash
46
+ git clone https://github.com/iweave/weave-node-manager.git
47
+ cd weave-node-manager
48
+ pip3 install -e .
49
+ ```
50
+
51
+ #### 5. Initialize and configure
52
+ ```bash
53
+ # Initialize with your rewards address
54
+ wnm --init --rewards_address 0xYourEthereumAddress
55
+
56
+ # Run in dry-run mode to test
57
+ wnm --dry_run
58
+
59
+ # Or run normally to start managing nodes
60
+ wnm
61
+ ```
62
+
63
+ #### 6. Optional: Add to cron for automatic management
64
+ ```bash
65
+ # Add to crontab (runs every minute)
66
+ crontab -e
67
+
68
+ # Add this line:
69
+ */1 * * * * /usr/local/bin/wnm >> ~/Library/Logs/autonomi/wnm-cron.log 2>&1
70
+ ```
71
+
72
+ **macOS Notes:**
73
+ - Uses `~/Library/Application Support/autonomi/node/` for data
74
+ - Uses `~/Library/Logs/autonomi/` for logs
75
+ - Nodes managed via launchd (`~/Library/LaunchAgents/`)
76
+ - No root/sudo access required
77
+
78
+ ### Linux (User-Level, Recommended)
79
+
80
+ Non-root installation using setsid for process management.
81
+
82
+ #### 1. Install antup (Autonomi binary manager)
83
+ ```bash
84
+ curl -sSL https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | bash
85
+ ```
86
+
87
+ #### 2. Download antnode binary
88
+ ```bash
89
+ ~/.local/bin/antup node
90
+ ```
91
+
92
+ #### 3. Install WNM from PyPI
93
+ ```bash
94
+ pip3 install wnm
95
+ ```
96
+
97
+ #### 4. Or install from source
98
+ ```bash
99
+ git clone https://github.com/iweave/weave-node-manager.git
100
+ cd weave-node-manager
101
+ pip3 install -e .
102
+ ```
103
+
104
+ #### 5. Initialize and configure
105
+ ```bash
106
+ # Initialize with your rewards address
107
+ wnm --init --rewards_address 0xYourEthereumAddress
108
+
109
+ # Run in dry-run mode to test
110
+ wnm --dry_run
111
+
112
+ # Or run normally
113
+ wnm
114
+ ```
115
+
116
+ #### 6. Optional: Add to cron
117
+ ```bash
118
+ crontab -e
119
+
120
+ # Add this line:
121
+ */1 * * * * ~/.local/bin/wnm >> ~/.local/share/autonomi/logs/wnm-cron.log 2>&1
122
+ ```
123
+
124
+ **Linux User-Level Notes:**
125
+ - Uses `~/.local/share/autonomi/node/` for data (XDG spec)
126
+ - Uses `~/.local/share/autonomi/logs/` for logs
127
+ - Nodes run as background processes (setsid)
128
+ - No root/sudo required
129
+
130
+ ### Linux (Root-Level, Production)
131
+
132
+ Root installation using systemd for process management.
133
+
134
+ #### 1. Install system dependencies
135
+ ```bash
136
+ sudo apt install -y python3.12-venv python3-pip
137
+ ```
138
+
139
+ #### 2. Install antup and antnode
140
+ ```bash
141
+ curl -sSL https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | bash
142
+ ~/.local/bin/antup node
143
+ sudo cp ~/.local/bin/antnode /usr/local/bin/
144
+ ```
145
+
146
+ #### 3. Install WNM
147
+ ```bash
148
+ sudo pip3 install wnm
149
+ ```
150
+
151
+ #### 4. Initialize as root
152
+ ```bash
153
+ # Migrate from existing anm installation
154
+ sudo wnm --init --migrate_anm
155
+
156
+ # Or initialize fresh
157
+ sudo wnm --init --rewards_address 0xYourEthereumAddress
158
+ ```
159
+
160
+ #### 5. Add to cron
161
+ ```bash
162
+ sudo crontab -e
163
+
164
+ # Add this line:
165
+ */1 * * * * /usr/local/bin/wnm >> /var/log/antnode/wnm-cron.log 2>&1
166
+ ```
167
+
168
+ **Linux Root-Level Notes:**
169
+ - Uses `/var/antctl/` for data (legacy anm compatibility)
170
+ - Uses `/var/log/antnode/` for logs
171
+ - Nodes managed via systemd (`/etc/systemd/system/`)
172
+ - Requires root/sudo access
173
+ - Supports migration from anm
174
+
175
+ ## Configuration
176
+
177
+ Configuration follows a multi-layer priority system (highest to lowest):
178
+
179
+ 1. **Command-line arguments**: `wnm --cpu_less_than 70 --node_cap 50`
180
+ 2. **Environment variables**: Set in `.env` file or shell
181
+ 3. **Config files**:
182
+ - macOS: `~/Library/Application Support/autonomi/config`
183
+ - Linux (user): `~/.local/share/autonomi/config`
184
+ - Linux (root): `/var/antctl/config`
185
+ 4. **Database-stored config**: Persisted in `colony.db` after initialization
186
+ 5. **Default values**: Built-in defaults
187
+
188
+ ### Key Configuration Parameters
189
+
190
+ Resource thresholds control when nodes are added or removed:
191
+
192
+ - `--cpu_less_than` / `--cpu_remove`: CPU percentage thresholds (default: 70% / 80%)
193
+ - `--mem_less_than` / `--mem_remove`: Memory percentage thresholds (default: 70% / 80%)
194
+ - `--hd_less_than` / `--hd_remove`: Disk usage percentage thresholds (default: 70% / 80%)
195
+ - `--desired_load_average` / `--max_load_average_allowed`: Load average thresholds
196
+ - `--node_cap`: Maximum number of nodes (default: 50)
197
+ - `--rewards_address`: Wallet address(es) for node rewards (required) - see Wallet Configuration below
198
+ - `--node_storage`: Root directory for node data (auto-detected per platform)
199
+
200
+ ### Wallet Configuration
201
+
202
+ The `--rewards_address` parameter supports multiple formats for flexible reward distribution:
203
+
204
+ #### Single Wallet
205
+ Use a single Ethereum address or named wallet:
206
+ ```bash
207
+ # Ethereum address
208
+ wnm --init --rewards_address 0xYourEthereumAddress
209
+
210
+ # Named wallet: "donate" (uses your custom donate_address or the community foucet if not deefined)
211
+ wnm --init --rewards_address donate
212
+
213
+ # Named wallet: "faucet" (always uses the autonomi community faucet address)
214
+ wnm --init --rewards_address faucet
215
+ ```
216
+
217
+ #### Weighted Distribution
218
+ Distribute rewards across multiple wallets using weighted random selection:
219
+ ```bash
220
+ # Format: wallet1:weight1,wallet2:weight2,...
221
+ wnm --init --rewards_address "0xYourAddress:100,faucet:1,donate:10"
222
+ ```
223
+
224
+ In this example:
225
+ - Your address receives ~90% of nodes (100 out of 111 weight)
226
+ - Faucet receives ~1% of nodes (1 out of 111 weight)
227
+ - Donate address receives ~9% of nodes (10 out of 111 weight)
228
+
229
+ **Key Features:**
230
+ - **Random per node**: Each new node randomly selects a wallet based on weights
231
+ - **Named wallets**: Use `faucet` (project faucet) or `donate` (your custom donation address)
232
+ - **Case-insensitive**: `faucet`, `FAUCET`, and `Faucet` all work
233
+ - **Mix addresses and names**: Combine Ethereum addresses with named wallets
234
+ - **Changeable**: Update `--rewards_address` anytime to change distribution for new nodes
235
+
236
+ **Examples:**
237
+ ```bash
238
+ # 50/50 split between your address and faucet
239
+ wnm --rewards_address "0xYourAddress:1,faucet:1"
240
+
241
+ # Your address only
242
+ wnm --rewards_address 0xYourAddress
243
+
244
+ # Mostly yours, small donation to faucet
245
+ wnm --rewards_address "0xYourAddress:99,faucet:1"
246
+
247
+ # Multiple addresses with custom weights
248
+ wnm --rewards_address "0xAddress1:100,0xAddress2:50,faucet:10"
249
+ ```
250
+
251
+ ### anm Migration (Linux Only)
252
+
253
+ Upon finding an existing [anm](https://github.com/safenetforum-community/NTracking/tree/main/anm) installation, wnm will:
254
+ 1. Disable anm by removing `/etc/cron.d/anm`
255
+ 2. Import configuration from `/var/antctl/config`
256
+ 3. Discover and import existing nodes from systemd
257
+ 4. Take over management of the cluster
258
+
259
+ Use `wnm --init --migrate_anm` to trigger migration.
260
+
261
+ ## Usage
262
+
263
+ ### Run Once
264
+ ```bash
265
+ # macOS or Linux
266
+ wnm
267
+
268
+ # With dry-run (no actual changes)
269
+ wnm --dry_run
270
+
271
+ # Initialize first time
272
+ wnm --init --rewards_address 0xYourEthereumAddress
273
+ ```
274
+
275
+ ### Run via Cron (Recommended)
276
+
277
+ WNM is designed to run every minute via cron, making one decision per cycle:
278
+
279
+ **macOS:**
280
+ ```bash
281
+ crontab -e
282
+ # Add: */1 * * * * /usr/local/bin/wnm >> ~/Library/Logs/autonomi/wnm-cron.log 2>&1
283
+ ```
284
+
285
+ **Linux (user):**
286
+ ```bash
287
+ crontab -e
288
+ # Add: */1 * * * * ~/.local/bin/wnm >> ~/.local/share/autonomi/logs/wnm-cron.log 2>&1
289
+ ```
290
+
291
+ **Linux (root):**
292
+ ```bash
293
+ sudo crontab -e
294
+ # Add: */1 * * * * /usr/local/bin/wnm >> /var/log/antnode/wnm-cron.log 2>&1
295
+ ```
296
+
297
+ ### Development Mode
298
+
299
+ For development with live code reloading:
300
+
301
+ **macOS (native):**
302
+ ```bash
303
+ python3 -m wnm --dry_run
304
+ ```
305
+
306
+ **Linux (Docker):**
307
+ ```bash
308
+ ./scripts/dev.sh
309
+ # Inside container:
310
+ python3 -m wnm --dry_run
311
+ ```
312
+
313
+ See `DOCKER-DEV.md` for comprehensive Docker development workflow.
314
+
315
+ ## Platform Support
316
+
317
+ See `PLATFORM-SUPPORT.md` for detailed information about:
318
+ - Platform-specific process managers (systemd, launchd, setsid)
319
+ - Firewall management (UFW, null)
320
+ - Path conventions per platform
321
+ - Binary management and upgrades
322
+ - Testing strategies
323
+
324
+ ## Contributing
325
+ Contributions are welcome! Please submit a pull request or open an issue for any enhancements or bug fixes.
326
+
327
+ ## License
328
+ This project is licensed under the MIT License. See the LICENSE file for more details.