Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Work In Progress] Gracefully reload the ZIM Library #734

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Optimus-NP
Copy link

@Optimus-NP Optimus-NP commented Feb 22, 2025

Fixes #729

Refactor and Improve Code Formatting in kiwix-serve.cpp

  • Introduced listenDirectoryChanges() function (Linux-only) to monitor directory changes and reload the library dynamically.
  • Used inotify to detect modifications in watched directories and trigger library updates.
  • Implemented a dedicated monitor thread to watch for changes in the specified directory.
  • Ensured proper synchronization and thread safety while handling directory monitoring.
  • Reformatted and improved code readability by adjusting indentation, spacing, and alignment.
  • Fixed inconsistent whitespace in function definitions, loops, and conditions.
  • Standardized #include ordering for better organization.
  • Reordered #include statements to maintain consistency across platforms.
  • Improved error handling by adding better structured try-catch blocks.
  • Standardized macro definitions and improved formatting for readability.
  • Improved logging messages for better debugging and clarity.

Testing

 /usr/local/bin/kiwix-serve --port=8080 --library /tmp/zimlibrary/linux_library.xml --monitorLibrary

After running the specified command, the console logs indicated a successful configuration reload following modifications to the file /tmp/zimlibrary/linux_library.xml. To verify the changes, I accessed the web interface at http://localhost:8080/ and confirmed that the library updates were applied as expected.

Refactor and Improve Code Formatting in kiwix-serve.cpp

- Introduced `listenDirectoryChanges()` function (Linux-only) to monitor directory changes and reload the library dynamically.
- Used `inotify` to detect modifications in watched directories and trigger library updates.
- Implemented a dedicated **monitor thread** to watch for changes in the specified directory.
- Ensured proper synchronization and thread safety while handling directory monitoring.
- Reformatted and improved code readability by adjusting indentation, spacing, and alignment.
- Fixed inconsistent whitespace in function definitions, loops, and conditions.
- Standardized `#include` ordering for better organization.
- Reordered `#include` statements to maintain consistency across platforms.
- Improved error handling by adding better structured `try-catch` blocks.
- Standardized macro definitions and improved formatting for readability.
- Improved logging messages for better debugging and clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Knowing when library has been reloaded
1 participant