Commit Graph

2526 Commits

Author SHA1 Message Date
Martin Bogomolni 9f3446b605 feat: Implement comprehensive memory management and stability improvements
🔧 Memory Management Enhancements:
- Add memory cleanup constants (MAX_CMD_HISTORY=1000, MAX_SEEN_NODES=500, MAX_MSG_HISTORY=100)
- Implement cleanup_memory() function to prevent unbounded list growth
- Add periodic cleanup every hour via watchdog process
- Clean up stale game tracker entries automatically
- Limit cmdHistory and msg_history sizes to prevent memory bloat

🚀 Async Task Management Improvements:
- Fix async task management in both mesh_bot.py and pong_bot.py
- Implement proper task cleanup and cancellation on shutdown
- Add task names for better debugging and monitoring
- Use asyncio.gather() with return_exceptions=True for better error handling
- Prevent task hanging and resource leaks

🛡️ Enhanced Resource Management:
- Improve exit_handler() with proper interface cleanup
- Add atexit.register() for automatic graceful shutdown
- Ensure all meshtastic interfaces are properly closed
- Save persistent data (BBS, email, SMS, game scores) on exit
- Perform final memory cleanup during shutdown

🔍 Better Exception Handling:
- Replace bare except: blocks with specific exception handling
- Add proper error logging throughout the codebase
- Improve BBS database operations with better error recovery
- Add try/catch blocks for file operations and imports

📈 System Stability Improvements:
- Prevent memory leaks from growing lists and dictionaries
- Add automatic cleanup of stale player tracking data
- Improve error recovery in watchdog and async loops
- Better handling of interface connection failures

These changes address critical memory management issues that could cause
the bot to consume increasing memory over time, eventually leading to
system instability. The improvements ensure long-term reliability and
better resource utilization.

Fixes: Memory leaks, async task hanging, resource cleanup issues
Improves: System stability, error handling, resource management
Tested: Code analysis and review completed
2025-10-05 23:45:40 -07:00
SpudGunMan 4e074a309f Update system.py 2025-10-05 23:05:55 -07:00
SpudGunMan f394f58b9f paxCounter 2025-10-05 22:30:03 -07:00
SpudGunMan 30bcee498d Update config.template 2025-10-05 22:24:35 -07:00
SpudGunMan 5c54ce0b70 better waypoint data 2025-10-05 21:50:56 -07:00
SpudGunMan b4684f49ff Update system.py 2025-10-05 21:38:19 -07:00
SpudGunMan c6c1e9f637 refactor more consumeMetadata 2025-10-05 21:13:39 -07:00
SpudGunMan 54540b1656 cleanup 2025-10-05 20:26:48 -07:00
SpudGunMan 006c9f58c6 enhance bbsLink 2025-10-05 19:44:00 -07:00
SpudGunMan 3d582e9b77 enhance import of BBS
for ssh copy
2025-10-05 19:20:44 -07:00
SpudGunMan 0578c0b233 more enhancing metadata 2025-10-05 19:00:34 -07:00
SpudGunMan 98ccf8708f enhanceTelemetry
logging and handlers for telemetry
2025-10-05 17:47:19 -07:00
SpudGunMan 47280f4330 Update bbstools.py
comment from https://github.com/SpudGunMan/meshing-around/issues/194
2025-10-05 15:26:50 -07:00
SpudGunMan 4b0b074ba7 mathWasntMathn'
@mesb1 thanks
2025-10-05 09:08:47 -07:00
SpudGunMan d8d79f46b5 Update README.md
@pdxlocations
2025-10-04 15:45:43 -07:00
SpudGunMan 1a49a81cf5 load_bbsdb with 'api'
allows for ssh file synch?
2025-10-04 12:54:20 -07:00
SpudGunMan 5c0b04f0b7 Update injectDM.py 2025-10-03 19:11:40 -07:00
SpudGunMan 8f1cb6265d Update injectDM.py 2025-10-03 19:07:25 -07:00
SpudGunMan c51a4584ae enhance bbsAPI
switch for diskIO
2025-10-03 19:06:14 -07:00
SpudGunMan 13ee6d4fd6 enhance bbsDM
enable a new 'API' to inject into the pkl file for DM's also see https://github.com/SpudGunMan/meshing-around/commit/2d44faac98bb977d9b3b9f840ca4dfbec71af3dc
2025-10-03 19:02:15 -07:00
SpudGunMan 2d44faac98 Create injectDM.py
Usage: python3 script/injectDM.py -s NODEID -d NODEID -m "message"
2025-10-03 18:15:57 -07:00
SpudGunMan 0a2daeac1f Update joke.py 2025-10-03 15:42:05 -07:00
SpudGunMan da7ba256d8 Update joke.py 2025-10-03 15:41:40 -07:00
SpudGunMan 42e99a0dc1 Update joke.py 2025-10-03 15:40:54 -07:00
SpudGunMan ca5896a015 Update locationdata.py 2025-10-03 15:35:04 -07:00
SpudGunMan ebe2636104 refactor riverflow 2025-10-03 15:34:03 -07:00
SpudGunMan 971a421d01 riverflow refactor 2025-10-03 15:15:40 -07:00
SpudGunMan 9d080de8f3 Update locationdata.py 2025-10-03 15:01:41 -07:00
SpudGunMan 5209092928 better riverflow logic 2025-10-03 14:54:12 -07:00
SpudGunMan 6439f49fb1 Update filemon.py 2025-10-03 12:28:47 -07:00
SpudGunMan c115cdf82f enhance x: with subprocess 2025-10-03 12:15:14 -07:00
SpudGunMan 63fccbdf3e Update config.template 2025-10-03 12:01:41 -07:00
SpudGunMan c23564d8b5 Update system.py 2025-10-02 19:37:57 -07:00
SpudGunMan 0b9db28951 Update README.md 2025-10-02 19:18:39 -07:00
SpudGunMan 1aa4eddb3b Update filemon.py 2025-10-02 19:07:37 -07:00
SpudGunMan a7de64b385 Update filemon.py 2025-10-02 19:03:15 -07:00
SpudGunMan 2e8206d4ec x:ShellCommands
this x: is a direct shell access from DM, to enable it needs the enable_runShellCmd, allowXcmd, xcmdChannel set. Make sure your secure.
2025-10-02 18:58:27 -07:00
SpudGunMan b47c13503b Update filemon.py 2025-10-02 13:37:17 -07:00
SpudGunMan a66dbd13fd Update config.template 2025-10-02 13:17:48 -07:00
SpudGunMan 02322cdf91 cleanup
fixes per https://github.com/SpudGunMan/meshing-around/issues/192
2025-10-02 04:51:40 -07:00
SpudGunMan 955d3681e9 Update joke.py 2025-10-01 11:41:59 -07:00
SpudGunMan 9d96c02870 catch em all 2025-09-29 16:59:13 -07:00
SpudGunMan c87dba1e06 fixWikiErrors 2025-09-29 16:58:34 -07:00
SpudGunMan 1c3d2f7f18 Update mesh_bot.py 2025-09-29 16:16:33 -07:00
SpudGunMan b53a7d3832 Update joke.py 2025-09-29 16:13:01 -07:00
SpudGunMan 99e74ae8c0 lower! 2025-09-28 18:22:56 -07:00
SpudGunMan 1bdfc3828f cleanup 2025-09-28 18:20:42 -07:00
SpudGunMan 26f39e76e6 somdays tabs killl me 2025-09-28 17:41:13 -07:00
SpudGunMan c49dcfbfc8 aarg 2025-09-28 17:38:59 -07:00
SpudGunMan 1008ec6afa yarp 2025-09-28 17:36:57 -07:00